Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add release workflow #18

Merged
merged 1 commit into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
categories:
- title: 'BREAKING CHANGES'
labels:
- 'BREAKING CHANGES'
- title: 'Features'
labels:
- 'feature'
- 'enhancement'
- title: 'Fixes'
labels:
- 'fix'
- 'bug'
- 'security'
- title: 'Dependencies'
collapse-after: 3
labels:
- 'dependencies'
- 'renovate'
- title: 'Documentation'
labels:
- 'document'
- 'documentation'
- title: 'Internal improvement'
labels:
- 'ci'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
version-resolver:
major:
labels:
- 'BREAKING CHANGES'
minor:
labels:
- 'feature'
- 'enhancement'
patch:
labels:
- 'bug'
- 'security'
default: patch
template: |
## [v$RESOLVED_VERSION](https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION)
## Changes
$CHANGES
56 changes: 56 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Release
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: write
# Comment out to enable these permissions if needed.
# packages: write
# deployments: write
# id-token: write

jobs:
draft_release:
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.release-drafter.outputs.tag_name }}
steps:
# Get next version
- uses: release-drafter/release-drafter@v5
id: release-drafter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Sample job for GitHub Actions repository.
# It creates GitHub Releases and push semver(major, minor, patch) git tags.
release:
name: Release
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch'
needs: draft_release
steps:
- uses: release-drafter/release-drafter@v5
id: release-drafter
with:
publish: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create semver outputs
uses: actions/github-script@v6
id: semver
with:
script: |
const VERSION = "${{ steps.release-drafter.outputs.tag_name }}"
const matched = VERSION.match(/(((v\d+)\.\d+).\d+)/)
core.setOutput('major', matched[3])
core.setOutput('minor', matched[2])
core.setOutput('patch', matched[1])
- uses: actions/checkout@v4
with:
ref: "${{ steps.release-drafter.outputs.tag_name }}"
- name: Update major and minor git tags
run: |
git push -f origin "refs/tags/${{ steps.release-drafter.outputs.tag_name }}:refs/tags/${{ steps.semver.outputs.major }}"
git push -f origin "refs/tags/${{ steps.release-drafter.outputs.tag_name }}:refs/tags/${{ steps.semver.outputs.minor }}"