chore: Update fixtures #81
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tag release | |
on: | |
pull_request: | |
types: [ closed ] | |
branches: | |
- dev | |
- release/* | |
jobs: | |
# Creates a new tag if a release branch is merged | |
tag-bump: | |
if: | | |
github.event.pull_request.merged == true && | |
((startsWith(github.event.pull_request.head.ref, 'release/') && github.event.pull_request.base.ref == 'dev') || | |
(startsWith(github.event.pull_request.head.ref, 'hotfix/') && startsWith(github.event.pull_request.base.ref, 'release/'))) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Git config | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get version | |
id: get-version | |
run: | | |
VERSION=$(echo "${{ github.event.pull_request.head.ref }}" | cut -d'/' -f 2) | |
RELEASE_BRANCH="${{ startsWith(github.event.pull_request.head.ref, 'release/') && github.event.pull_request.head.ref || github.event.pull_request.base.ref }}" | |
PATH=$(echo "${{ github.event.pull_request.head.ref }}" | cut -d'/' -f 2 | cut -d'.' -f 1) | |
if [[ "${{ startsWith(github.event.pull_request.head.ref, 'release/') }}" == "true" ]]; then | |
VERSION="${VERSION}.0" | |
fi | |
git tag -a $VERSION -m "$VERSION" origin/$RELEASE_BRANCH | |
git push origin $VERSION --follow-tags | |
echo "path=$PATH" | tee -a "$GITHUB_OUTPUT" | |
echo "version=$VERSION" | tee -a "$GITHUB_OUTPUT" | |
echo "RELEASE_BRANCH=$RELEASE_BRANCH" | tee -a "$GITHUB_ENV" | |
- name: Get latest release reference | |
id: get-latest-release | |
run: | | |
if [[ "${{ startsWith(github.event.pull_request.head.ref, 'release/') }}" == "true" ]]; then | |
REGEX=$(echo "${{ github.event.pull_request.head.ref }}" | cut -d'/' -f 2 | cut -d'.' -f 1) | |
LATEST_RELEASE=$(gh release list --repo $GITHUB_REPOSITORY --limit 100 | grep -Ei "$REGEX" | head -n 1) | |
if [ -z "$LATEST_RELEASE" ]; then | |
FIRST_COMMIT=$(git rev-list --max-parents=0 dev#refs/heads/) | |
echo "The first commit on branch dev is $FIRST_COMMIT" | |
echo "latest_release=$FIRST_COMMIT" | tee -a "$GITHUB_OUTPUT" | |
else | |
echo "Found release: $LATEST_RELEASE" | |
echo "latest_release=$LATEST_RELEASE" | tee -a "$GITHUB_OUTPUT" | |
fi | |
else | |
REGEX=$(echo "${{ github.event.pull_request.base.ref }}" | cut -d'/' -f 2) | |
LATEST_RELEASE=$(gh release list --repo $GITHUB_REPOSITORY --limit 100 | grep -Ei "$REGEX" | head -n 1) | |
echo "Found release: $LATEST_RELEASE" | |
echo "latest_release=$LATEST_RELEASE" | tee -a "$GITHUB_OUTPUT" | |
fi | |
- name: Build Changelog | |
id: github_release | |
uses: mikepenz/release-changelog-builder-action@v4 | |
with: | |
path: "./${{ steps.get-version.outputs.path }}" | |
fromTag: ${{ steps.get-latest-release.outputs.latest_release }} | |
toTag: ${{ steps.get-version.outputs.version }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Release | |
uses: ncipollo/release-action@v1 | |
with: | |
body: ${{ steps.github_release.outputs.changelog }} | |
tag: ${{ steps.get-version.outputs.version }} | |
commit: ${{ env.RELEASE_BRANCH }} | |
allowUpdates: true |