diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6c24a0cf..46566ed6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,6 +16,10 @@ jobs: with: fetch-depth: 0 + - name: Fetch annotated tags + run: | + git fetch origin "refs/tags/$GITHUB_REF:refs/tags/$GITHUB_REF" + - name: Set up Go uses: actions/setup-go@v2 with: @@ -42,10 +46,17 @@ jobs: git config user.name 'githooks-bot' git config user.email 'githooks-bot@users.noreply.github.com' + # Check we got an annotated tag. + [ "$(git cat-file -t "$TRIGGER_TAG")" = "tag" ] || { + echo "Tag '$TRIGGER_TAG' is not an annotated tag." + exit 1 + } + # Gets the message on the annotated commit: deref() { git for-each-ref "refs/tags/$TRIGGER_TAG" --format="%($1)" ; }; + # Creates a new tag with the same message, including trailing headers. - git tag "$RELEASE_TAG" -a -m "$(deref contents)" + git tag -a -m "$(deref contents)" "$RELEASE_TAG" git tag "githooks/$RELEASE_TAG" - name: Define Release Branch @@ -57,25 +68,34 @@ jobs: RELEASE_BRANCH="main" RELEASE_VERSION="${RELEASE_TAG##v}" - regex="^Release-Branch:\s+(.*)$" + echo "Get release branch on tag '$RELEASE_TAG'." + # Gets the message on the annotated commit: deref() { git for-each-ref "refs/tags/$RELEASE_TAG" --format="%($1)" ; }; + deref contents + + regex="^Release-Branch:\s+(.*)$" if deref contents | grep -qE "$regex"; then RELEASE_BRANCH=$(deref contents | grep -E "$regex" | sed -E "s/$regex/\1/") || { echo "Release-Branch trailer is wrong." exit 1 } + [ -n "$RELEASE_BRANCH" ] || { + echo "Release-Branch trailer is empty." + exit 1 + } fi + # Fetch the branch. git fetch --depth 50 origin "$RELEASE_BRANCH" # Check if its reachable. [ -n "$(git rev-list --first-parent \ - --ancestry-path + --ancestry-path \ "$RELEASE_TAG^..origin/$RELEASE_BRANCH")" ] || { echo "Tag is not reachable from '$RELEASE_BRANCH' (--first-parent) !" >&2 exit 1 diff --git a/README.md b/README.md index b45786fc..86d22e92 100644 --- a/README.md +++ b/README.md @@ -1514,10 +1514,10 @@ matches the regex `^Update-NoSkip: *true`, than this version **will not be skipped**. This feature enables to enforce an update to a specific version. In some cases this is useful (serialization changes etc.). -The single-line commit trailers `^Update-Info: *(.*)` on version tagged commits -are used to assemble a small changelog during update, which is presented to the -user. The single line can contain important information/links to relevant fixes -and changes. +The single-line commit trailers `^Update-Info: *(.*)` (multiple ones allowed) on +the annotated tag is used to assemble a small changelog during update, which is +presented to the user. The single line can contain important information/links +to relevant fixes and changes. You can also check for updates at any time by executing [`git hooks update`](docs/cli/git_hooks_update.md) or using diff --git a/nix/pkgs/version.json b/nix/pkgs/version.json index f339f7b9..80cc1aad 100644 --- a/nix/pkgs/version.json +++ b/nix/pkgs/version.json @@ -1 +1,3 @@ -{ "version": "3.0.0" } +{ + "version": "3.0.0-rc1" +} diff --git a/scripts/release.sh b/scripts/release.sh index cddb8bac..2a44a7c1 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -34,7 +34,7 @@ function commit_version_file() { jq ".version |= \"$version\"" nix/pkgs/version.json >"$temp" mv "$temp" nix/pkgs/version.json - if git diff --quiet --exit-code; then + if ! git diff --quiet --exit-code; then git add nix/pkgs/version.json git commit -m "np: Update version to '$version'" fi