Skip to content

Commit

Permalink
chore(pre-release): refactor and simplify workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
SRodi committed Jan 22, 2025
1 parent eff12f7 commit ed306bd
Showing 1 changed file with 8 additions and 27 deletions.
35 changes: 8 additions & 27 deletions .github/workflows/release-candidate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Generate Release Candidate

on:
push:
branches:
- "RC-*"
branches: ["RC-*"]
tags: ["v*"]

jobs:
create-release-candidate:
Expand All @@ -12,36 +12,17 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Get the latest release tag
id: get_latest_release
run: echo "::set-output name=tag::$(git describe --tags `git rev-list --tags --max-count=1`)"

- name: Generate release notes
id: generate_release_notes
run: |
LAST_TAG=${{ steps.get_latest_release.outputs.tag }}
COMMITS=$(git log ${LAST_TAG}..HEAD --pretty=format:"- %s")
echo "::set-output name=notes::This is the release candidate for version ${{ github.ref }}.\\n\\n$COMMITS"
- name: Calculate new version
id: calculate_version
run: |
LATEST_VERSION=$(git describe --tags `git rev-list --tags --max-count=1` | sed 's/^v//;s/-.*//')
NEW_VERSION=$(echo $LATEST_VERSION | awk -F. -v OFS=. '{$NF += 1 ; print}')
RC_COUNT=$(git tag -l "v${NEW_VERSION}.rc*" | wc -l)
NEW_RC_TAG="v${NEW_VERSION}.rc$((RC_COUNT + 1))"
echo "::set-output name=rc_tag::$NEW_RC_TAG"
- name: Create and Push release candidate tag
run: |
git tag ${{ steps.calculate_version.outputs.rc_tag }}
git push origin ${{ steps.calculate_version.outputs.rc_tag }}
COMMITS=$(git log ${{ github.ref_name }}..HEAD --pretty=format:"- %s")
echo "NOTES=\"This is the release candidate for version ${{ github.ref_name }}.\\n\\n$COMMITS\"" >> $GITHUB_ENV
- name: Create release candidate
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.calculate_version.outputs.rc_tag }}
name: Release Candidate ${{ steps.calculate_version.outputs.rc_tag }}
body: ${{ steps.generate_release_notes.outputs.notes }}
tag_name: ${{ github.ref_name }}
name: Release Candidate ${{ github.ref_name }}
body: $NOTES
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit ed306bd

Please sign in to comment.