Skip to content

Commit

Permalink
Update release GH job (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
squadgazzz authored Jul 12, 2024
1 parent b231d14 commit 913b642
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,38 @@ jobs:
# Requires "Read and Write access to code" permission
token: ${{ secrets.RELEASE_ACTION_ACCESS_TOKEN }}

- name: Check for changes since last tag
id: check_changes
- name: Fetch latest release version tag
id: fetch_tag
run: |
LATEST_TAG=$(git tag --merged=main --sort=-committerdate | head -n 1)
CHANGES=$(git log $LATEST_TAG..HEAD --oneline)
if [[ -z "$CHANGES" ]]; then
echo "No changes since the last tag."
else
echo "Changes detected since the last tag."
echo "has_changes=true" >> $GITHUB_OUTPUT
fi
- name: Create Tag
if: ${{ steps.check_changes.outputs.has_changes }}
id: tag_version
run: |
# Extracts the latest version tag, bumps the minor version
LATEST_VERSION=$(curl -s https://api.github.com/repos/gnosis/solvers/releases/latest | jq -r '.tag_name')
if ! [[ "$LATEST_VERSION" =~ ^v[0-9]+\.[0-9]+\..* ]]; then
echo "Invalid tag format, cannot bump version of: $LATEST_VERSION"
exit 1
fi
MAJOR=$(echo $LATEST_VERSION | cut -d. -f1)
MINOR=$(echo $LATEST_VERSION | cut -d. -f2)
echo "latest=$LATEST_VERSION" >> $GITHUB_OUTPUT
- name: Check for changes since last tag
run: |
git diff --quiet ${{ steps.fetch_tag.outputs.latest }}..HEAD || echo "CHANGES_DETECTED=true" >> $GITHUB_ENV
- name: No changes detected
if: env.CHANGES_DETECTED != 'true'
run: echo "No commits since previous release. Skipping release."

- name: Create Tag
id: tag_version
if: env.CHANGES_DETECTED == 'true'
run: |
MAJOR=$(echo ${{ steps.fetch_tag.outputs.latest }} | cut -d. -f1)
MINOR=$(echo ${{ steps.fetch_tag.outputs.latest }} | cut -d. -f2)
NEW_MINOR=$((MINOR+1))
NEW_TAG="${MAJOR}.${NEW_MINOR}.0"
echo ::set-output name=tag::$NEW_TAG
echo "tag=$NEW_TAG" >> $GITHUB_OUTPUT
git tag $NEW_TAG
git push origin --tags
- name: "Create release"
if: ${{ steps.check_changes.outputs.has_changes }}
if: env.CHANGES_DETECTED == 'true'
uses: "actions/github-script@v6"
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
Expand Down

0 comments on commit 913b642

Please sign in to comment.