Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: check for both tag and release #1657

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,39 @@ jobs:

- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Check if any changes since last tag
- name: Check if any changes since last release
id: check
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git fetch --tags
if [ -z "$(git tag --points-at HEAD)" ]; then
echo "Nothing points at HEAD, so we need a new tag+release."
TAG=$(git tag --points-at HEAD)
if [ -z "$TAG" ]; then
echo "No tag points at HEAD, so we need a new tag and then a new release."
echo "need_release=yes" >> $GITHUB_OUTPUT
else
echo "A tag already points to head, no need for a new tag+release."
echo "need_release=no" >> $GITHUB_OUTPUT
RELEASE=$(gh release view "$TAG" --json tagName --jq '.tagName' || echo "none")
if [ "$RELEASE" == "$TAG" ]; then
echo "A release exists for tag $TAG, which has the latest changes, so no need for a new tag or release."
echo "need_release=no" >> $GITHUB_OUTPUT
else
echo "Tag $TAG exists, but no release is associated. Need a new release."
echo "need_release=yes" >> $GITHUB_OUTPUT
echo "existing_tag=$TAG" >> $GITHUB_OUTPUT
fi
fi

- name: Bump version and push tag
id: create_tag
uses: mathieudutour/github-tag-action@a22cf08638b34d5badda920f9daf6e72c477b07b # v6.2
if: steps.check.outputs.need_release == 'yes'
if: steps.check.outputs.need_release == 'yes' && steps.check.outputs.existing_tag == ''
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
if: steps.check.outputs.need_release == 'yes'
with:
ref: ${{ steps.create_tag.outputs.new_tag }}
ref: ${{ steps.check.outputs.existing_tag || steps.create_tag.outputs.new_tag }}

- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
if: steps.check.outputs.need_release == 'yes'
Expand Down Expand Up @@ -76,3 +86,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_GITHUB_TOKEN: ${{ steps.octo-sts.outputs.token }}
TAG: ${{ steps.check.outputs.existing_tag || steps.create_tag.outputs.new_tag }}
jdolitsky marked this conversation as resolved.
Show resolved Hide resolved
Loading