From f9c704b069c72c5ad6826c2ba93cfbb81ba80ff5 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 21 Nov 2026 00:36:29 +0000 Subject: [PATCH] Release workflow: merging a new version into main releases it A push to main that changes the version in src-tauri/tauri.conf.json (scripts/set-version.mjs) now starts the Release workflow. If the version changed in that push and the tag v does not exist yet, the commit is built, tested, tagged and published like with "Run workflow"; the release notes take the version's CHANGELOG.md section. So a release is just a pull request that sets the version and the changelog entry. - Trigger: push to main with a path filter on tauri.conf.json (path filters do not apply to tag pushes, so those work as before). - Version job: for main it compares the version with the one before the push and checks for the tag; new output "build" skips every other job when nothing is released (other tauri.conf.json edits, a version that was already tagged by hand). Warns when CHANGELOG.md has no section. - Publish: the Tag step also runs for main (tag created with the workflow token on the built commit, no second run). - "Announce build" and "Report failed build" stay tag-push only. - Run workflow, tag pushes and releases created on GitHub are unchanged. - Docs: releasing.md describes the pull request as the way to release; CHANGELOG.md gets an Unreleased section with this change. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_017w9FQja85UGJGWm8LrX9WT --- .github/workflows/release.yml | 57 ++++++++++++++++++----- CHANGELOG.md | 16 +++++-- docs/src/development/releasing.md | 75 ++++++++++++++++++++----------- 3 files changed, 106 insertions(+), 42 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 374f2c1..fc3d396 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,10 @@ name: Release -# A release is cut with "Run workflow" on the Actions tab (enter the version; the tag is -# created on the selected branch's commit) or by pushing a version tag: +# A release is cut by merging a new version into main: when a push to main changes the +# version in src-tauri/tauri.conf.json (node scripts/set-version.mjs 0.2.0) and the tag +# v does not exist yet, that commit is released and tagged. The release notes take +# the version's section of CHANGELOG.md. Other ways: "Run workflow" on the Actions tab (enter +# the version; the tag is created on the selected branch's commit) or pushing a version tag: # git tag v0.2.0 && git push origin v0.2.0 # Every platform is built and tested first. Then the release is created as a draft with all # downloads (DMG, Windows installer and portable exe, AppImage/deb/rpm, rcmd archives, @@ -16,6 +19,9 @@ name: Release on: push: tags: ['v[0-9]+.[0-9]+.[0-9]+*'] + # a new version merged into main; path filters do not apply to tag pushes + branches: [main] + paths: [src-tauri/tauri.conf.json] workflow_dispatch: inputs: version: @@ -55,17 +61,38 @@ jobs: version: ${{ steps.version.outputs.version }} tag: ${{ steps.version.outputs.tag }} prerelease: ${{ steps.version.outputs.prerelease }} + # false for a push to main that does not release anything: all other jobs are skipped + build: ${{ steps.version.outputs.build }} steps: - uses: actions/checkout@v7 - if: github.event_name == 'pull_request' + if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref_type == 'branch') - name: Determine version id: version env: INPUT_VERSION: ${{ inputs.version }} + BEFORE: ${{ github.event.before }} run: | - case "$GITHUB_EVENT_NAME" in - workflow_dispatch) v="${INPUT_VERSION#v}" ;; - pull_request) v="$(jq -r .version src-tauri/tauri.conf.json)" ;; + build=true + case "$GITHUB_EVENT_NAME/$GITHUB_REF_TYPE" in + workflow_dispatch/*) v="${INPUT_VERSION#v}" ;; + pull_request/*) v="$(jq -r .version src-tauri/tauri.conf.json)" ;; + push/branch) + # main: release the version of tauri.conf.json if this push changed it and it + # has no tag yet (a tag pushed by hand, or an earlier release, wins) + v="$(jq -r .version src-tauri/tauri.conf.json)" + old="" + if git fetch --quiet --depth=1 origin "$BEFORE" 2>/dev/null; then + old="$(git show "$BEFORE:src-tauri/tauri.conf.json" 2>/dev/null | jq -r .version)" || old="" + fi + if [ "$v" = "$old" ]; then + echo "Version $v unchanged, nothing to release" | tee -a "$GITHUB_STEP_SUMMARY" + build=false + elif git ls-remote --exit-code --tags "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" "refs/tags/v$v" >/dev/null; then + echo "Tag v$v exists already, nothing to release" | tee -a "$GITHUB_STEP_SUMMARY" + build=false + elif [ -z "$(bash scripts/changelog.sh "$v" 2>/dev/null)" ]; then + echo "::warning::CHANGELOG.md has no section for $v, the release notes only list the pull requests" + fi ;; *) v="${GITHUB_REF_NAME#v}" ;; esac if ! [[ "$v" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$ ]]; then @@ -80,13 +107,14 @@ jobs: echo "version=$v" echo "tag=v$v" echo "prerelease=$([[ "$v" == *-* ]] && echo true || echo false)" + echo "build=$build" } >> "$GITHUB_OUTPUT" - echo "Version **v$v**" >> "$GITHUB_STEP_SUMMARY" + if [ "$build" = true ]; then echo "Version **v$v**" >> "$GITHUB_STEP_SUMMARY"; fi announce: name: Announce build needs: prepare - if: github.event_name == 'push' + if: github.event_name == 'push' && github.ref_type == 'tag' runs-on: ubuntu-latest timeout-minutes: 5 permissions: @@ -119,12 +147,15 @@ jobs: checks: name: Checks - if: github.event_name != 'pull_request' # CI runs on the pull request itself + needs: prepare + # CI runs on the pull request itself + if: github.event_name != 'pull_request' && needs.prepare.outputs.build == 'true' uses: ./.github/workflows/ci.yml desktop: name: Desktop (${{ matrix.name }}) needs: prepare + if: needs.prepare.outputs.build == 'true' timeout-minutes: 90 strategy: fail-fast: false @@ -230,6 +261,7 @@ jobs: rcmd: name: rcmd (${{ matrix.name }}) needs: prepare + if: needs.prepare.outputs.build == 'true' timeout-minutes: 60 strategy: fail-fast: false @@ -403,10 +435,11 @@ jobs: exit 1 fi - name: Tag - if: github.event_name == 'workflow_dispatch' + if: github.event_name == 'workflow_dispatch' || github.ref_type == 'branch' run: | set -euo pipefail - # A pushed tag brings its own. For "Run workflow" it is created now on the built commit. + # A pushed tag brings its own. For "Run workflow" and a version merged into main it is + # created now on the built commit. # Tags made with the workflow token start no second run of this workflow, so # publishing a draft by hand later does not rebuild everything. if sha=$(gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/$TAG" --jq .object.sha 2>/dev/null); then @@ -471,7 +504,7 @@ jobs: build-failed: name: Report failed build needs: [prepare, checks, desktop, rcmd, downloads, publish] - if: ${{ (failure() || cancelled()) && github.event_name == 'push' && needs.prepare.result == 'success' }} + if: ${{ (failure() || cancelled()) && github.event_name == 'push' && github.ref_type == 'tag' && needs.prepare.result == 'success' }} runs-on: ubuntu-latest timeout-minutes: 5 permissions: diff --git a/CHANGELOG.md b/CHANGELOG.md index 3640c0e..190eade 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,18 @@ All notable changes to Rust Commander are listed here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow [Semantic Versioning](https://semver.org/). -The release workflow puts the section of the released version into the release notes on -GitHub (see [Releasing](docs/src/development/releasing.md)), so add an entry here before -cutting a release. +Changes collect under *Unreleased*. For a release, that section is renamed to the version +and date in the pull request that sets the new version; merging it publishes the release, and +the release notes on GitHub take this section (see +[Releasing](docs/src/development/releasing.md)). + +## [Unreleased] + +### Changed + +- **Releases start by themselves:** merging a pull request that sets a new version + (`node scripts/set-version.mjs `) into `main` builds, tags and publishes the + release. Run workflow, pushing a tag and releases created on GitHub keep working. ## [0.0.2] - 2026-11-20 @@ -125,5 +134,6 @@ First version: a two-panel file manager in Rust and Tauri with a web mode, LAN d a read-only remote explorer for SSH hosts, an editor with linting and formatting, and release builds for macOS, Windows and Linux plus the `rcmd` CLI. +[Unreleased]: https://github.com/bobnautic/rustCommander/compare/v0.0.2...HEAD [0.0.2]: https://github.com/bobnautic/rustCommander/compare/v0.0.1-alpha...v0.0.2 [0.0.1-alpha]: https://github.com/bobnautic/rustCommander/releases/tag/v0.0.1-alpha diff --git a/docs/src/development/releasing.md b/docs/src/development/releasing.md index 8fb7a26..5d399e8 100644 --- a/docs/src/development/releasing.md +++ b/docs/src/development/releasing.md @@ -7,39 +7,60 @@ as `-beta.1`). ## Cutting a release -1. Add a section `## [0.2.0] - ` to `CHANGELOG.md` with the changes since the previous - release (*Added*, *Changed*, *Fixed*, … as in [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)). - The workflow puts this section into the release notes, above the generated list of pull - requests. Optional, but keeps `main` in step with the releases: set the version in the - repository as well. Merge both. +A release is a pull request that sets the new version. Merging it releases it. + +1. On a branch, set the version and add a section `## [0.2.0] - ` to `CHANGELOG.md` + with the changes since the previous release (*Added*, *Changed*, *Fixed*, … as in + [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)). The workflow puts this section + into the release notes, between the download table and the generated list of pull + requests. ```bash node scripts/set-version.mjs 0.2.0 # Cargo workspace + Cargo.lock, tauri.conf.json, package.json files + # edit CHANGELOG.md git commit -am "Release 0.2.0" ``` -2. Start the release on GitHub under **Actions → Release → Run workflow**: pick the branch - (`main`), enter the version (`0.2.0`) and run it. The tag `v0.2.0` is created on that - branch's latest commit once everything is built. Pushing a tag works the same way: - - ```bash - git tag v0.2.0 - git push origin v0.2.0 - ``` - - About 25 minutes later the release is on the Releases page, with all downloads. - - A release created by hand works as well: **Releases → Draft a new release**, choose a - *new* tag `v0.2.0`, write the notes and **Publish release**. Publishing creates the tag, - which starts the workflow. Until the files are built (about 25 minutes) the release shows - a note with a link to the build; then the files and the download table are added above - the notes written there. The tag must not exist before, otherwise no build starts. This - way needs the repository setting *immutable releases* to be off, because the files are - added after publishing. - -The workflow always builds with the version from the tag (it runs `set-version.mjs` itself), -so the installers, the app and `rcmd --version` carry that version even if step 1 was -skipped. +2. Open a pull request. Because it changes `src-tauri/tauri.conf.json`, the Release workflow + builds and checks all downloads on it (as workflow artifacts, nothing is published). + +3. Merge it. The push to `main` changes the version in `src-tauri/tauri.conf.json`, so the + workflow releases that commit: it builds and tests everything, creates the tag `v0.2.0` + on it and publishes the release. About 25 minutes later the release is on the Releases + page, with all downloads. + +A push to `main` releases only when it **changes** the version and the tag `v` +does **not** exist yet. Other changes to `tauri.conf.json` start the workflow too, but it +stops after the *Version* job (all other jobs show as skipped). If the changelog has no +section for the version, the run shows a warning and the release notes list only the pull +requests. + +### Other ways to start a release + +- **Actions → Release → Run workflow**: pick the branch (`main`), enter the version + (`0.2.0`) and run it. The tag `v0.2.0` is created on that branch's latest commit once + everything is built. Useful to release a commit without changing the version in the + repository, or with the **draft** / **dry-run** options below. +- **Pushing a tag**: + + ```bash + git tag v0.2.0 + git push origin v0.2.0 + ``` + + If the version merged into `main` already has its tag (for example because it was pushed + by hand first), the push to `main` releases nothing. +- **A release created by hand**: **Releases → Draft a new release**, choose a *new* tag + `v0.2.0`, write the notes and **Publish release**. Publishing creates the tag, which starts + the workflow. Until the files are built (about 25 minutes) the release shows a note with a + link to the build; then the files and the download table are added above the notes + written there. The tag must not exist before, otherwise no build starts. This way needs the + repository setting *immutable releases* to be off, because the files are added after + publishing. + +The workflow always builds with the version of the release (it runs `set-version.mjs` +itself), so the installers, the app and `rcmd --version` carry that version even when it was +started with a tag or **Run workflow** without setting the version in the repository. ## What the workflow does