From b6359e836bedaa5bbe38acfa41f0d5428e5c6d37 Mon Sep 17 00:00:00 2001 From: Victor Phos Date: Tue, 6 Oct 2026 14:11:23 +0200 Subject: [PATCH 1/2] Bump the AUR pkgver in bump-version and skip CI on release commits --- scripts/bump-version.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/bump-version.sh b/scripts/bump-version.sh index 357578c..9247d3d 100755 --- a/scripts/bump-version.sh +++ b/scripts/bump-version.sh @@ -34,9 +34,12 @@ echo "Bumping version: $CURRENT -> $NEW_VERSION" sed -i "0,/^version = \"$CURRENT\"/s//version = \"$NEW_VERSION\"/" Cargo.toml cargo update --offline --workspace >/dev/null 2>&1 || cargo update --workspace >/dev/null +# Keep the AUR package in step with the release. +sed -i "s/^pkgver=.*/pkgver=${NEW_VERSION}/" aur/PKGBUILD + # Create git commit and tag -git add Cargo.toml Cargo.lock -git commit -m "chore: release v${NEW_VERSION}" +git add Cargo.toml Cargo.lock aur/PKGBUILD +git commit -m "chore: release v${NEW_VERSION} [skip ci]" git tag -a "v${NEW_VERSION}" -m "Release v${NEW_VERSION}" echo "" From e5a29498e1225df8fa49812278d33dbc5e55e52e Mon Sep 17 00:00:00 2001 From: Victor Phos Date: Tue, 6 Oct 2026 14:11:23 +0200 Subject: [PATCH 2/2] Release automatically on every merge to main Bump the version, tag it, and publish a release with Linux packages and a Windows .exe. --- .github/workflows/release.yml | 117 ++++++++++++++++++++++++++++++---- 1 file changed, 106 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 29727d7..f98bf00 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,17 +1,72 @@ name: Release +# Every push to main (i.e. every merge) bumps the version, tags it, and +# publishes a release with Linux and Windows builds. on: push: - tags: - - "v*" + branches: [main] + workflow_dispatch: + inputs: + bump: + description: Version bump (overrides the commit-based guess) + type: choice + options: [patch, minor, major] + default: patch + +concurrency: + group: release + cancel-in-progress: false + +permissions: + contents: write jobs: - build: + version: + # Skip the commit this workflow pushes itself. + if: "!contains(github.event.head_commit.message, '[skip ci]')" runs-on: ubuntu-latest - permissions: - contents: write + outputs: + version: ${{ steps.bump.outputs.version }} steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Bump version, commit and tag + id: bump + env: + INPUT_BUMP: ${{ inputs.bump }} + run: | + # Bump level: manual input wins; otherwise look at commits since the + # last tag. "BREAKING"/"!:" -> major, "feat" -> minor, else patch. + LAST_TAG=$(git describe --tags --abbrev=0 --match 'v*' 2>/dev/null || true) + RANGE=${LAST_TAG:+$LAST_TAG..HEAD} + SUBJECTS=$(git log --format=%s $RANGE) + if [ -n "$INPUT_BUMP" ]; then + BUMP="$INPUT_BUMP" + elif echo "$SUBJECTS" | grep -qiE 'BREAKING|^[a-z]+(\(.*\))?!:'; then + BUMP=major + elif echo "$SUBJECTS" | grep -qiE '^feat(\(.*\))?:'; then + BUMP=minor + else + BUMP=patch + fi + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + ./scripts/bump-version.sh "$BUMP" + git push origin HEAD:main --follow-tags + echo "version=$(git describe --tags --abbrev=0 | sed 's/^v//')" >> "$GITHUB_OUTPUT" + + build-linux: + needs: version + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: v${{ needs.version.outputs.version }} - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable @@ -33,9 +88,9 @@ jobs: - name: Build run: cargo build --release --locked --bin chelete - - name: Get version from tag + - name: Get version id: version - run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + run: echo "VERSION=${{ needs.version.outputs.version }}" >> $GITHUB_OUTPUT - name: Create tarball run: | @@ -85,11 +140,51 @@ jobs: EOF dpkg-deb --build "$DEB_DIR" - - name: Create GitHub Release - uses: softprops/action-gh-release@v2 + - uses: actions/upload-artifact@v4 with: - generate_release_notes: true - files: | + name: linux + path: | dist/*.tar.gz dist/*.deb dist/*.AppImage + + build-windows: + needs: version + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + with: + ref: v${{ needs.version.outputs.version }} + + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + + - name: Build + run: cargo build --release --locked --bin chelete + + - name: Name binary + shell: pwsh + run: | + New-Item -ItemType Directory -Path dist -Force | Out-Null + Copy-Item target/release/chelete.exe "dist/chelete_${{ needs.version.outputs.version }}_windows_x86_64.exe" + + - uses: actions/upload-artifact@v4 + with: + name: windows + path: dist/*.exe + + release: + needs: [version, build-linux, build-windows] + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v4 + with: + path: artifacts + merge-multiple: true + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + tag_name: v${{ needs.version.outputs.version }} + generate_release_notes: true + files: artifacts/*