diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 634b317..f44c4d4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,9 +1,9 @@ -name: Release +name: CLI Release on: push: tags: - - "*.*.*" + - "cli-v*.*.*" jobs: build: @@ -102,7 +102,7 @@ jobs: ext="" [[ "${{ matrix.name }}" == windows-* ]] && ext=".exe" bin="target/${{ matrix.target }}/release/watchexec${ext}" - version=$(echo "${{ github.ref }}" | cut -d/ -f3 | cut -dv -f2) + version=$(grep -oP '[0-9.]+' <<< "${{ github.ref }}") dst="watchexec-${version}-${{ matrix.target }}" mkdir "$dst" strip "$bin" || true @@ -113,7 +113,7 @@ jobs: shell: bash run: | set -euxo pipefail - version=$(echo "${{ github.ref }}" | cut -d/ -f3 | cut -dv -f2) + version=$(grep -oP '[0-9.]+' <<< "${{ github.ref }}") dst="watchexec-${version}-${{ matrix.target }}" tar cavf "$dst.tar.xz" "$dst" - name: Archive (deb) @@ -121,7 +121,7 @@ jobs: shell: bash run: | set -euxo pipefail - version=$(echo "${{ github.ref }}" | cut -d/ -f3 | cut -dv -f2) + version=$(grep -oP '[0-9.]+' <<< "${{ github.ref }}") dst="watchexec-${version}-${{ matrix.target }}" mkdir -p "deb/$dst" cd "deb/$dst" @@ -150,7 +150,7 @@ jobs: shell: bash run: | set -euxo pipefail - version=$(echo "${{ github.ref }}" | cut -d/ -f3 | cut -dv -f2) + version=$(grep -oP '[0-9.]+' <<< "${{ github.ref }}") dst="watchexec-${version}-${{ matrix.target }}" 7z a "$dst.zip" "$dst" - uses: softprops/action-gh-release@v1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ddedcb6..02de8a8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -74,8 +74,8 @@ A release goes through these steps: 8. Check for any dependency updates with `cargo outdated -R`. -9. Run `bin/version 1.2.3` where `1.2.3` is the new version number. This will tag and push, - triggering the GitHub Action for releases. +9. Run `bin/cli-version 1.2.3` where `1.2.3` is the new version number. This will tag and push, + triggering the GitHub Action for releases. Use `bin/lib-version` to release a library update. 10. Wait for all builds to complete, then attach the draft release to the tag, and publish it. diff --git a/bin/version b/bin/cli-version similarity index 90% rename from bin/version rename to bin/cli-version index 0274838..29c46cf 100755 --- a/bin/version +++ b/bin/cli-version @@ -42,12 +42,11 @@ echo "Next version to be $newver ($date), creating..." sed -E -i "s/version=\"$extver.0\"/version=\"$newver.0\"/1" cli/watchexec.exe.manifest sed -E -i "s/^version = \"$extver\"/version = \"$newver\"/1" cli/Cargo.toml -sed -E -i "s/^version = \"$extver\"/version = \"$newver\"/1" lib/Cargo.toml cargo check -git commit -am "$newver" -git tag -sam "$newver" "$newver" +git commit -am "cli: v$newver" +git tag -sam "watchexec-cli $newver" "cli-v$newver" echo "Pushing to upstream" git push --follow-tags $upstream $mainbranch diff --git a/bin/lib-version b/bin/lib-version new file mode 100755 index 0000000..e3aec88 --- /dev/null +++ b/bin/lib-version @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +set -euo pipefail + +app="watchexec" +mainbranch="main" +upstream_rx="watchexec/" + +curbranch=$(git rev-parse --abbrev-ref HEAD) +if [[ "$curbranch" != "$mainbranch" ]]; then + echo "Current branch is not $mainbranch, abort!" + exit 1 +fi + +gitstatus=$(git status --untracked-files=no --porcelain) +if [[ ! -z "$gitstatus" ]]; then + echo "Uncommited files and changes, abort!" + exit 2 +fi + +upstream=$(git remote -v | grep -i "$upstream_rx" -m1 | awk '{print $1}') +echo "Upstream remote discovered as: $upstream" + +echo "Pulling from upstream" +git pull --rebase --autostash $upstream $mainbranch + +echo "Fetching tags from upstream" +git fetch --tags "$upstream" + +extver=$(grep -P '^version =' lib/Cargo.toml | head -n1 | cut -d'"' -f2) +echo "(Version from lib/Cargo.toml: $extver)" + +newver="$1" + +if [[ "$newver" == "$extver" ]]; then + echo "New and existing versions are the same, abort!" + exit 3 +fi + +date=$(date +%Y-%m-%d) +echo "Next version to be $newver ($date), creating..." + +sed -E -i "s/^version = \"$extver\"/version = \"$newver\"/1" lib/Cargo.toml + +cargo check + +git commit -am "lib: v$newver" +git tag -sam "watchexec $newver" "lib-v$newver" + +echo "Pushing to upstream" +git push --follow-tags $upstream $mainbranch diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 906e140..256488c 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -37,10 +37,10 @@ features = [] embed-resource = "1.6.1" [package.metadata.binstall] -pkg-url = "{ repo }/releases/download/{ version }/watchexec-{ version }-{ target }.tar.xz" +pkg-url = "{ repo }/releases/download/cli-v{ version }/watchexec-{ version }-{ target }.tar.xz" bin-dir = "watchexec-{ version }-{ target }/{ bin }{ format }" pkg-fmt = "txz" [package.metadata.binstall.overrides.x86_64-pc-windows-msvc] -pkg-url = "{ repo }/releases/download/{ version }/watchexec-{ version }-{ target }.zip" +pkg-url = "{ repo }/releases/download/cli-v{ version }/watchexec-{ version }-{ target }.zip" pkg-fmt = "zip" diff --git a/lib/Cargo.toml b/lib/Cargo.toml index dbc7a91..9eaa697 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -32,10 +32,10 @@ version = "0.3.9" features = ["ioapiset", "jobapi2", "tlhelp32"] [package.metadata.binstall] -pkg-url = "{ repo }/releases/download/{ version }/watchexec-{ version }-{ target }.tar.xz" +pkg-url = "{ repo }/releases/download/cli-v{ version }/watchexec-{ version }-{ target }.tar.xz" bin-dir = "watchexec-{ version }-{ target }/{ bin }{ format }" pkg-fmt = "txz" [package.metadata.binstall.overrides.x86_64-pc-windows-msvc] -pkg-url = "{ repo }/releases/download/{ version }/watchexec-{ version }-{ target }.zip" +pkg-url = "{ repo }/releases/download/cli-v{ version }/watchexec-{ version }-{ target }.zip" pkg-fmt = "zip"