-
Notifications
You must be signed in to change notification settings - Fork 7
56 lines (54 loc) · 1.78 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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@v6
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@v6
id: release-drafter
with:
publish: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create semver outputs
uses: actions/github-script@v7
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 }}"