diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index c2586fe..56e40b9 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -1,15 +1,7 @@ name: Android on: - push: - branches: [main] - paths: - - "android/**" - - "crates/ezd-android/**" - - "crates/ezd-client-core/**" - - "crates/ezd-proto/**" - - "crates/ezd-link/**" - - ".github/workflows/android.yml" + # Pushes to main run through the release workflow, which calls this one. pull_request: paths: - "android/**" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 37dc6ef..fe97e1a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,7 @@ name: CI on: - push: - branches: [main] + # Pushes to main run through the release workflow, which calls this one. pull_request: workflow_call: diff --git a/.github/workflows/linux-packages.yml b/.github/workflows/linux-packages.yml index 45bbe8b..d2b57b0 100644 --- a/.github/workflows/linux-packages.yml +++ b/.github/workflows/linux-packages.yml @@ -1,8 +1,7 @@ name: Linux packages on: - push: - branches: [main] + # Pushes to main run through the release workflow, which calls this one. pull_request: # Called by the release workflow. workflow_call: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1c1ee6d..2481555 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,10 +1,12 @@ name: Release -# Push a tag `v` (see docs/releasing.md) to build everything and publish a -# GitHub Release. "Run workflow" with dry_run builds the same set and uploads it as the -# `release-preview` artifact without creating a release. +# Every push to main publishes a GitHub pre-release tagged `v+`. +# Pushing a tag `v` (see docs/releasing.md) publishes the release of that version. +# "Run workflow" with dry_run builds the same set and uploads it as the `release-preview` artifact +# without creating a release. on: push: + branches: [main] tags: ["v*"] workflow_dispatch: inputs: @@ -16,6 +18,11 @@ on: permissions: contents: read +# Releases of different pushes never cancel each other. +concurrency: + group: release-${{ github.ref }} + cancel-in-progress: false + env: CARGO_TERM_COLOR: always @@ -25,18 +32,43 @@ jobs: runs-on: ubuntu-24.04 outputs: version: ${{ steps.version.outputs.version }} + tag: ${{ steps.version.outputs.tag }} + mode: ${{ steps.version.outputs.mode }} steps: - uses: actions/checkout@v4 - id: version + env: + DRY_RUN: ${{ inputs.dry_run }} run: | version=$(sed -n '/^\[workspace\.package\]/,/^\[/{s/^version *= *"\(.*\)"/\1/p}' Cargo.toml) [ -n "$version" ] || { echo "cannot read the workspace version from Cargo.toml"; exit 1; } echo "version=$version" >> "$GITHUB_OUTPUT" echo "Workspace version: $version" - if [ "$GITHUB_REF_TYPE" = tag ] && [ "$GITHUB_REF_NAME" != "v$version" ]; then - echo "::error::tag $GITHUB_REF_NAME does not match the workspace version (expected v$version)" + # mode: release (a v* tag), prerelease (a push to main) or preview (no release). + if [ "$GITHUB_REF_TYPE" = tag ]; then + if [ "$GITHUB_REF_NAME" != "v$version" ]; then + echo "::error::tag $GITHUB_REF_NAME does not match the workspace version (expected v$version)" + exit 1 + fi + tag=$GITHUB_REF_NAME + if [ "$GITHUB_EVENT_NAME" = push ] || [ "$DRY_RUN" = false ]; then mode=release; else mode=preview; fi + elif [ "$GITHUB_EVENT_NAME" = push ] && [ "$GITHUB_REF" = refs/heads/main ]; then + tag="v$version+$GITHUB_RUN_NUMBER" + mode=prerelease + if git ls-remote --exit-code --tags origin "refs/tags/$tag" >/dev/null; then + echo "$tag already exists, building a preview only" + mode=preview + fi + elif [ "$GITHUB_EVENT_NAME" = workflow_dispatch ] && [ "$DRY_RUN" = false ]; then + echo "::error::a real release needs a tag: run the workflow on a v* tag, not on $GITHUB_REF_NAME" exit 1 + else + tag= + mode=preview fi + echo "tag=$tag" >> "$GITHUB_OUTPUT" + echo "mode=$mode" >> "$GITHUB_OUTPUT" + echo "Tag: ${tag:-none}, mode: $mode" ci: name: CI @@ -61,20 +93,10 @@ jobs: contents: write env: VERSION: ${{ needs.version.outputs.version }} - DRY_RUN: ${{ inputs.dry_run }} + TAG: ${{ needs.version.outputs.tag }} + MODE: ${{ needs.version.outputs.mode }} GH_TOKEN: ${{ github.token }} steps: - - name: Decide between release and preview - id: mode - run: | - if [ "$GITHUB_REF_TYPE" = tag ] && { [ "$GITHUB_EVENT_NAME" = push ] || [ "$DRY_RUN" = false ]; }; then - echo "release=true" >> "$GITHUB_OUTPUT" - elif [ "$GITHUB_EVENT_NAME" = workflow_dispatch ] && [ "$DRY_RUN" = false ]; then - echo "::error::a real release needs a tag: run the workflow on a v* tag, not on $GITHUB_REF_NAME" - exit 1 - else - echo "release=false" >> "$GITHUB_OUTPUT" - fi - uses: actions/download-artifact@v4 with: pattern: ezdisplay-* @@ -109,14 +131,19 @@ jobs: ls -l release cat release/SHA256SUMS - name: Create the GitHub Release - if: steps.mode.outputs.release == 'true' + if: env.MODE == 'release' run: | prerelease= - case "$GITHUB_REF_NAME" in *-*) prerelease=--prerelease ;; esac - gh release create "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --verify-tag \ + case "$TAG" in *-*) prerelease=--prerelease ;; esac + gh release create "$TAG" --repo "$GITHUB_REPOSITORY" --verify-tag \ --title "ezdisplay $VERSION" --generate-notes $prerelease release/* + - name: Create the GitHub pre-release of this build + if: env.MODE == 'prerelease' + run: | + gh release create "$TAG" --repo "$GITHUB_REPOSITORY" --target "$GITHUB_SHA" \ + --title "ezdisplay $VERSION (build $GITHUB_RUN_NUMBER)" --generate-notes --prerelease release/* - name: Upload the preview - if: steps.mode.outputs.release != 'true' + if: env.MODE == 'preview' uses: actions/upload-artifact@v4 with: name: release-preview diff --git a/AGENTS.md b/AGENTS.md index a2fb8c6..38c187c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -24,3 +24,12 @@ These rules apply to the whole repository. Component notes live next to the code Do not name pen-tablet vendors or commercial drawing apps in code, strings, docs, tests or commit messages; describe the behaviour instead (for example "graphics tablet", "drawing apps"). The platforms the app runs on or talks to (Android, Samsung and the S Pen, KDE, Windows) and open-source apps used as test examples (Krita) are fine. + +## Versioning +- The version is `version` in `[workspace.package]` of the root `Cargo.toml` (crates, packages and the Android app + follow it). Every push to `main` publishes a GitHub pre-release `v+`; a `vX.Y.Z` tag publishes + the release (see `docs/releasing.md`). +- Bump the version in its own commit (`Bump the version to X.Y.Z`, with `cargo update -w` for `Cargo.lock`) before + every tagged release; never tag a release under the previous version. Patch (`x.y.Z`) for fixes and small, + self-contained changes (including a single small feature), minor (`x.Y.0`) for medium changes (several features, a + reworked screen or flow), major (`X.0.0`) for a large overhaul; keep the pre-release suffix (`-alpha`). diff --git a/Cargo.lock b/Cargo.lock index d74a63f..94fbf85 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1450,7 +1450,7 @@ dependencies = [ [[package]] name = "ezd-android" -version = "0.1.0-alpha.1" +version = "0.2.0-alpha" dependencies = [ "android_logger", "ezd-client-core", @@ -1469,7 +1469,7 @@ dependencies = [ [[package]] name = "ezd-client-core" -version = "0.1.0-alpha.1" +version = "0.2.0-alpha" dependencies = [ "ezd-link", "ezd-proto", @@ -1480,7 +1480,7 @@ dependencies = [ [[package]] name = "ezd-fake-client" -version = "0.1.0-alpha.1" +version = "0.2.0-alpha" dependencies = [ "anyhow", "clap", @@ -1500,7 +1500,7 @@ dependencies = [ [[package]] name = "ezd-ffmpeg" -version = "0.1.0-alpha.1" +version = "0.2.0-alpha" dependencies = [ "ezd-host-core", "ezd-proto", @@ -1511,7 +1511,7 @@ dependencies = [ [[package]] name = "ezd-host" -version = "0.1.0-alpha.1" +version = "0.2.0-alpha" dependencies = [ "anyhow", "clap", @@ -1531,7 +1531,7 @@ dependencies = [ [[package]] name = "ezd-host-core" -version = "0.1.0-alpha.1" +version = "0.2.0-alpha" dependencies = [ "ezd-link", "ezd-proto", @@ -1542,7 +1542,7 @@ dependencies = [ [[package]] name = "ezd-host-linux" -version = "0.1.0-alpha.1" +version = "0.2.0-alpha" dependencies = [ "ash", "ashpd", @@ -1560,7 +1560,7 @@ dependencies = [ [[package]] name = "ezd-host-service" -version = "0.1.0-alpha.1" +version = "0.2.0-alpha" dependencies = [ "ezd-ffmpeg", "ezd-host-core", @@ -1577,7 +1577,7 @@ dependencies = [ [[package]] name = "ezd-host-windows" -version = "0.1.0-alpha.1" +version = "0.2.0-alpha" dependencies = [ "ezd-ffmpeg", "ezd-host-core", @@ -1591,7 +1591,7 @@ dependencies = [ [[package]] name = "ezd-input" -version = "0.1.0-alpha.1" +version = "0.2.0-alpha" dependencies = [ "ezd-proto", "serde", @@ -1600,7 +1600,7 @@ dependencies = [ [[package]] name = "ezd-link" -version = "0.1.0-alpha.1" +version = "0.2.0-alpha" dependencies = [ "ezd-proto", "socket2", @@ -1611,7 +1611,7 @@ dependencies = [ [[package]] name = "ezd-proto" -version = "0.1.0-alpha.1" +version = "0.2.0-alpha" dependencies = [ "postcard", "serde", @@ -1621,7 +1621,7 @@ dependencies = [ [[package]] name = "ezd-tray" -version = "0.1.0-alpha.1" +version = "0.2.0-alpha" dependencies = [ "auto-launch", "clap", diff --git a/Cargo.toml b/Cargo.toml index 65506d3..99a0650 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ resolver = "3" members = ["crates/*"] [workspace.package] -version = "0.1.0-alpha.1" +version = "0.2.0-alpha" edition = "2024" license = "MIT OR Apache-2.0" authors = ["LibreStatic"] diff --git a/README.md b/README.md index 14a04a7..6b0e7da 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ and no telemetry, and everything travels through the cable. ## Status -ezdisplay is in **alpha** ([`v0.1.0-alpha.1`](https://github.com/LibreStatic/ezdisplay/releases)). +ezdisplay is in **alpha** (see the [releases](https://github.com/LibreStatic/ezdisplay/releases); every change merged to `main` is published as a pre-release). Working today, over USB with ADB: | | Windows | KDE Plasma 6 (Wayland) | diff --git a/docs/releasing.md b/docs/releasing.md index 7ee994c..25bed10 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -1,12 +1,27 @@ # Releasing -A release is a `vX.Y.Z` tag. The *Release* workflow builds every package from that commit and -publishes them in one GitHub Release. +The *Release* workflow builds every package from one commit and publishes them in one GitHub Release: + +- **Every push to `main`** publishes a pre-release tagged `v+` (for example + `v0.2.0-alpha+57`), so each merged change can be tried at once. The tag is created by the release. +- **A `vX.Y.Z` tag** publishes the release of that version. Tags containing `-` (for example + `v0.2.0-alpha`) are published as pre-releases. The workflow fails at once if the tag does not + match the workspace version. + +## Versioning + +The version is `version` in `[workspace.package]` of the root `Cargo.toml`; every crate, the +packages and the Android app (`versionName`, and `versionCode` derived from it) follow it. Bump it +in its own commit (`Bump the version to X.Y.Z`) before tagging a release, choosing the part by the +size of the changes since the last release: patch (`x.y.Z`) for fixes and small, self-contained +changes (including a single small feature), minor (`x.Y.0`) for medium changes (several features, a +reworked screen or flow), major (`X.0.0`) for a large overhaul. Keep the pre-release suffix +(`-alpha`) while the project is in alpha. Never tag a release under the previous version. ## Steps -1. Bump `version` in `[workspace.package]` of the root `Cargo.toml` (every crate follows it) and run - `cargo check --workspace` so `Cargo.lock` is updated. Merge that to `main`. +1. Bump the version as above and run `cargo update -w` so `Cargo.lock` follows. Merge that to + `main` (which also publishes a pre-release of it). 2. Optional dry run: *Actions, Release, Run workflow* on `main` with `dry_run` ticked (the default). It runs the whole pipeline and uploads the files as the `release-preview` artifact, without creating a release. @@ -17,18 +32,15 @@ publishes them in one GitHub Release. git push origin vX.Y.Z ``` - Tags containing `-` (for example `v0.2.0-rc1`) are published as pre-releases. The workflow - fails at once if the tag does not match the workspace version. - ## What the workflow does | Job | What it does | | --- | --- | -| `version` | Reads the workspace version and checks it against the tag. | +| `version` | Reads the workspace version, checks it against the tag and picks the tag of a `main` pre-release (skipped if that tag already exists). | | `ci` | Calls `ci.yml`: fmt, clippy and tests on Linux, the Windows build and installer (`ezdisplay-windows-installer`). | | `android` | Calls `android.yml`: the APKs (`ezdisplay-android-apks`). | | `linux` | Calls `linux-packages.yml`: the Arch package (`ezdisplay-arch`), one `.deb` per distro (`ezdisplay-deb-ubuntu24.04`, `-debian13`, `-ubuntu26.04`), the AppImage (`ezdisplay-appimage`) and its sources (`ezdisplay-appimage-sources`), plus a smoke test of the AppImage on a clean Debian 13. | -| `publish` | Runs only when all of the above pass. Collects the release files, writes `SHA256SUMS` and creates the release with generated notes (or uploads `release-preview` on a dry run). | +| `publish` | Runs only when all of the above pass. Collects the release files, writes `SHA256SUMS` and creates the release or the `main` pre-release with generated notes (or uploads `release-preview` on a dry run or when the pre-release tag already exists). | The release assets are: @@ -40,8 +52,8 @@ The release assets are: - `ezdisplay--full-debug.apk` and `ezdisplay--play-debug.apk`; - `SHA256SUMS`. -The same workflows also run on every push to `main` and on pull requests; the artifacts of those -runs are the way to try a build before tagging. +Pull requests run `ci.yml`, `android.yml` and `linux-packages.yml` on their own; their artifacts are +the way to try a change before it is merged. On `main` those workflows run only through *Release*. ## GPL obligations of the AppImage