-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (62 loc) · 2.01 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
57
58
59
60
61
62
63
64
65
66
67
68
---
# Update versions and create release PR
# Source: https://www.thisdot.co/blog/tag-and-release-your-project-with-github-actions-workflows
# https://goreleaser.com/ci/actions/#tag-fetching
#
# - Manually triggered "release-prepare.yml" workflow will create a PR
# - This PR will do some minor tweaks to ready for release (such as increment the version across files)
# - Upon merging the PR, "release" job defined here will trigger, which will:
# - create a tag
# - do the actual release with goreleaser
name: release
on:
pull_request:
types:
- closed
permissions:
contents: write # To create a new release
jobs:
release:
runs-on: ubuntu-latest
if: startsWith(github.event.pull_request.title, 'Release:') && github.event.pull_request.merged == true
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: stable
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 'latest'
- name: Install dependencies
run: npm install
- name: Set up Git
run: |
git config user.name "Release bot"
git config user.email "[email protected]"
- name: Get current version
id: get_version
run: |
git branch --show-current
git pull
echo "version=v$(npm pkg get version | tr -d '\"')" >> "${GITHUB_OUTPUT}"
- name: Create tag
run: |
NEXT_VERSION=${{ steps.get_version.outputs.version }}
git pull
git tag -a "${NEXT_VERSION}" -m "${NEXT_VERSION}"
git push --follow-tags
git checkout "${NEXT_VERSION}"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
workdir: action
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}