Skip to content

Commit

Permalink
chore: add workflow for automatically creating GitHub releases
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed May 22, 2024
1 parent f9209e4 commit 893cdfe
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Create GitHub Release

on:
push:
branches:
- main

permissions:
contents: write
pull-requests: write

jobs:
create-github-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Determine current version in pubspec.yaml
id: pubspec-version-number
run: |
PUBSPEC_VERSION=$(yq ".version" pubspec.yaml)
echo "pubspec-version=$PUBSPEC_VERSION" >> $GITHUB_OUTPUT
- name: Check if version tag already exists
id: tag-check
run: |
TAG=v${{ steps.pubspec-version-number.outputs.pubspec-version }}
if git show-ref --tags --verify --quiet "refs/tags/${TAG}"; then
echo "Version tag $TAG already exists, not creating a new release."
else
echo "new-tag=$TAG" >> $GITHUB_OUTPUT
fi
- name: Generate release notes
uses: orhun/git-cliff-action@v3
if: ${{ steps.tag-check.outputs.new-tag != '' }}
with:
config: cliff.toml
args: --verbose --unreleased --strip header --tag ${{ steps.pubspec-version-number.outputs.pubspec-version }}
env:
OUTPUT: CHANGES.md
GITHUB_REPO: ${{ github.repository }}

- name: Create new GitHub release if tag does not exist yet
uses: ncipollo/release-action@v1
if: ${{ steps.tag-check.outputs.new-tag != '' }}
with:
tag: ${{ steps.tag-check.outputs.new-tag }}
bodyFile: CHANGES.md
name: Version ${{ steps.pubspec-version-number.outputs.pubspec-version }}
token: ${{ secrets.BOT_TOKEN }}

0 comments on commit 893cdfe

Please sign in to comment.