Skip to content

Commit a52c8e1

Browse files
authored
Merge pull request #2 from persevie/rc/0.1.0
Release MVP (v0.1.0)
2 parents 3e3354b + e1b305f commit a52c8e1

10 files changed

Lines changed: 1477 additions & 1 deletion

File tree

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
determine_release:
13+
name: Determine if release is needed
14+
runs-on: ubuntu-latest
15+
outputs:
16+
SHOULD_RELEASE: ${{ steps.release_check.outputs.SHOULD_RELEASE }}
17+
NEW_TAG: ${{ steps.release_check.outputs.NEW_TAG }}
18+
steps:
19+
- name: Checkout Code
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Determine if release is needed
25+
id: release_check
26+
shell: bash
27+
run: |
28+
git fetch --tags
29+
CURRENT_VERSION=$(grep '^version = ' Cargo.toml | head -n1 | awk -F\" '{print $2}')
30+
echo "Current version: $CURRENT_VERSION"
31+
if git rev-parse "v$CURRENT_VERSION" >/dev/null 2>&1; then
32+
echo "Tag v$CURRENT_VERSION already exists. No release needed."
33+
echo "SHOULD_RELEASE=false" >> $GITHUB_OUTPUT
34+
else
35+
echo "No existing tag for version $CURRENT_VERSION. Release is needed."
36+
echo "SHOULD_RELEASE=true" >> $GITHUB_OUTPUT
37+
echo "NEW_TAG=v$CURRENT_VERSION" >> $GITHUB_OUTPUT
38+
fi
39+
40+
build:
41+
name: Build
42+
runs-on: ${{ matrix.runs-on }}
43+
needs: determine_release
44+
if: needs.determine_release.outputs.SHOULD_RELEASE == 'true'
45+
strategy:
46+
matrix:
47+
include:
48+
- name: linux_x86_64
49+
runs-on: ubuntu-latest
50+
target: x86_64-unknown-linux-gnu
51+
artifact_name: grimoire-css-watcher-linux-x86_64
52+
artifact_path: target/x86_64-unknown-linux-gnu/release/grimoire-css-watcher
53+
- name: macos_x86_64
54+
runs-on: macos-latest
55+
target: x86_64-apple-darwin
56+
artifact_name: grimoire-css-watcher-macos-x86_64
57+
artifact_path: target/x86_64-apple-darwin/release/grimoire-css-watcher
58+
- name: macos_arm64
59+
runs-on: macos-latest
60+
target: aarch64-apple-darwin
61+
artifact_name: grimoire-css-watcher-macos-arm64
62+
artifact_path: target/aarch64-apple-darwin/release/grimoire-css-watcher
63+
- name: windows_x86_64
64+
runs-on: windows-latest
65+
target: x86_64-pc-windows-msvc
66+
artifact_name: grimoire-css-watcher-windows-x86_64.exe
67+
artifact_path: target/x86_64-pc-windows-msvc/release/grimoire-css-watcher.exe
68+
69+
steps:
70+
- name: Checkout Code
71+
uses: actions/checkout@v4
72+
with:
73+
fetch-depth: 0
74+
75+
- name: Set up Rust
76+
uses: actions-rs/toolchain@v1
77+
with:
78+
profile: minimal
79+
toolchain: stable
80+
target: ${{ matrix.target }}
81+
82+
- name: Cache Cargo registry
83+
uses: actions/cache@v4
84+
with:
85+
path: ~/.cargo/registry
86+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
87+
restore-keys: |
88+
${{ runner.os }}-cargo-registry-
89+
90+
- name: Cache Cargo git
91+
uses: actions/cache@v4
92+
with:
93+
path: ~/.cargo/git
94+
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
95+
restore-keys: |
96+
${{ runner.os }}-cargo-git-
97+
98+
- name: Cache Cargo build
99+
uses: actions/cache@v4
100+
with:
101+
path: target
102+
key: ${{ runner.os }}-build-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
103+
restore-keys: |
104+
${{ runner.os }}-build-${{ matrix.target }}-
105+
106+
- name: Build project
107+
run: cargo build --release --target ${{ matrix.target }}
108+
109+
- name: Prepare artifact
110+
run: |
111+
mkdir -p artifacts
112+
cp "${{ matrix.artifact_path }}" "artifacts/${{ matrix.artifact_name }}"
113+
114+
- name: Upload artifacts
115+
uses: actions/upload-artifact@v4
116+
with:
117+
name: ${{ matrix.artifact_name }}
118+
path: artifacts/${{ matrix.artifact_name }}
119+
120+
publish:
121+
name: Publish to crates.io
122+
runs-on: ubuntu-latest
123+
needs: [determine_release, build]
124+
if: needs.determine_release.outputs.SHOULD_RELEASE == 'true'
125+
steps:
126+
- name: Checkout Code
127+
uses: actions/checkout@v4
128+
129+
- name: Set up Rust
130+
uses: actions-rs/toolchain@v1
131+
with:
132+
profile: minimal
133+
toolchain: stable
134+
135+
- name: Cache Cargo registry
136+
uses: actions/cache@v4
137+
with:
138+
path: ~/.cargo/registry
139+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
140+
restore-keys: |
141+
${{ runner.os }}-cargo-registry-
142+
143+
- name: Cache Cargo git
144+
uses: actions/cache@v4
145+
with:
146+
path: ~/.cargo/git
147+
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
148+
restore-keys: |
149+
${{ runner.os }}-cargo-git-
150+
151+
- name: Publish to crates.io
152+
env:
153+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
154+
run: |
155+
cargo login ${{ secrets.CARGO_REGISTRY_TOKEN }}
156+
cargo publish
157+
158+
release:
159+
name: Release
160+
runs-on: ubuntu-latest
161+
needs: [determine_release, publish]
162+
if: needs.determine_release.outputs.SHOULD_RELEASE == 'true'
163+
steps:
164+
- name: Checkout Code
165+
uses: actions/checkout@v4
166+
with:
167+
fetch-depth: 0
168+
169+
- name: Download artifacts
170+
uses: actions/download-artifact@v4
171+
with:
172+
path: ./artifacts
173+
174+
- name: Create and push tag
175+
run: |
176+
git config user.name "${{ github.actor }}"
177+
git config user.email "${{ github.actor }}@users.noreply.github.com"
178+
git tag -a "${{ needs.determine_release.outputs.NEW_TAG }}" -m "Release ${{ needs.determine_release.outputs.NEW_TAG }}"
179+
git push origin "${{ needs.determine_release.outputs.NEW_TAG }}"
180+
181+
- name: Create GitHub Release
182+
uses: softprops/action-gh-release@v1
183+
with:
184+
tag_name: ${{ needs.determine_release.outputs.NEW_TAG }}
185+
files: ./artifacts/**/*
186+
body: "Release of grimoire-css-watcher version ${{ needs.determine_release.outputs.NEW_TAG }}"
187+
draft: false
188+
prerelease: false
189+
env:
190+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/quality.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Quality
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- 'main'
7+
- 'rc/**'
8+
9+
jobs:
10+
lint_and_test:
11+
name: Lint and test
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Set up Rust
20+
uses: actions-rs/toolchain@v1
21+
with:
22+
profile: minimal
23+
toolchain: stable
24+
25+
- name: Cache cargo registry
26+
uses: actions/cache@v4
27+
with:
28+
path: ~/.cargo/registry
29+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
30+
restore-keys: |
31+
${{ runner.os }}-cargo-registry-
32+
33+
- name: Cache cargo index
34+
uses: actions/cache@v4
35+
with:
36+
path: ~/.cargo/git
37+
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
38+
restore-keys: |
39+
${{ runner.os }}-cargo-git-
40+
41+
- name: Cache cargo build
42+
uses: actions/cache@v4
43+
with:
44+
path: target
45+
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
46+
restore-keys: |
47+
${{ runner.os }}-cargo-build-
48+
49+
- name: Check formatting with rustfmt
50+
run: cargo fmt -- --check
51+
52+
- name: Run clippy
53+
run: cargo clippy -- -D warnings
54+
55+
- name: Run tests
56+
run: cargo test
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Version Checks
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
version_check:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout Code
13+
uses: actions/checkout@v4
14+
15+
- name: Extract Branch Name
16+
run: |
17+
echo "PR head ref: ${{ github.head_ref }}"
18+
BRANCH_NAME="${{ github.head_ref }}"
19+
echo "Branch Name: $BRANCH_NAME"
20+
21+
- name: Determine Expected Version
22+
id: expected_version
23+
run: |
24+
BRANCH_NAME="${{ github.head_ref }}"
25+
if [[ "$BRANCH_NAME" == rc/* ]]; then
26+
EXPECTED_VERSION="${BRANCH_NAME#rc/}"
27+
echo "version=$EXPECTED_VERSION" >> $GITHUB_OUTPUT
28+
elif [[ "$BRANCH_NAME" == hotfix/* ]]; then
29+
git fetch --tags
30+
LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
31+
if [ -z "$LATEST_TAG" ]; then
32+
echo "No existing tags found. Cannot proceed with hotfix versioning."
33+
exit 1
34+
fi
35+
IFS='.' read -r -a VERSION_PARTS <<< "${LATEST_TAG#v}"
36+
MAJOR="${VERSION_PARTS[0]}"
37+
MINOR="${VERSION_PARTS[1]}"
38+
PATCH="${VERSION_PARTS[2]}"
39+
PATCH=$((PATCH + 1))
40+
EXPECTED_VERSION="${MAJOR}.${MINOR}.${PATCH}"
41+
echo "version=$EXPECTED_VERSION" >> $GITHUB_OUTPUT
42+
else
43+
echo "Not an rc/* or hotfix/* branch. Skipping version check."
44+
exit 0
45+
fi
46+
47+
- name: Check Version Consistency
48+
if: steps.expected_version.outputs.version
49+
run: |
50+
CARGO_VERSION=$(grep '^version = ' Cargo.toml | head -n 1 | awk -F\" '{print $2}')
51+
echo "Version in Cargo.toml: $CARGO_VERSION"
52+
echo "Expected version: ${{ steps.expected_version.outputs.version }}"
53+
if [ "$CARGO_VERSION" != "${{ steps.expected_version.outputs.version }}" ]; then
54+
echo "Version mismatch! Cargo.toml version ($CARGO_VERSION) does not match expected version (${{ steps.expected_version.outputs.version }})."
55+
exit 1
56+
else
57+
echo "Version matches."
58+
fi

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ target/
1414
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
1515
# and can be added to the global gitignore or merged into this file. For a more nuclear
1616
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
17-
#.idea/
17+
#.idea/
18+
19+
.DS_Store

0 commit comments

Comments
 (0)