Skip to content

Sync from develop to main #9

Sync from develop to main

Sync from develop to main #9

Workflow file for this run

name: Generate tag
on:
pull_request:
types: [closed]
concurrency:
group: generate-tag
jobs:
create_tag:
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' && contains(github.event.pull_request.labels.*.name, 'auto-tag')
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
new_version: ${{ steps.determine_version.outputs.new_version }}
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up git
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Determine new version
id: determine_version
run: |
latest_tag=$(git tag --list --sort=-version:refname | grep -m1 -E '^[0-9]+\.[0-9]+$' || true)
if [ -z "$latest_tag" ]; then
new_version="1.0"
else
IFS=. read -r major minor <<< "$latest_tag"
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'semver:major') }}" == "true" ]]; then
new_version="$((major + 1)).0"
else
new_version="$major.$((minor + 1))"
fi
fi
echo "new_version=$new_version" >> "$GITHUB_OUTPUT"
- name: Create new tag
run: |
new_version="${{ steps.determine_version.outputs.new_version }}"
git tag -a "$new_version" -m "Release $new_version" "${{ github.event.pull_request.merge_commit_sha }}"
git push origin "$new_version"
create_issue:
needs: create_tag
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Create issue for new tag
env:
GH_TOKEN: ${{ github.token }}
run: |
issue_title="The tag \`${{ needs.create_tag.outputs.new_version }}\` was created"
issue_body=$'The **${{ needs.create_tag.outputs.new_version }}** tag for the **main branch** has been created.\nPlease consider creating a release of this tag, if a release isn\'t needed, you can close this issue.\n\n[Click here to create a release of **${{ needs.create_tag.outputs.new_version }}** tag](../releases/new?tag=${{ needs.create_tag.outputs.new_version }})'
gh issue create --repo "${{ github.repository }}" --title "$issue_title" --body "$issue_body" --label auto-tag