-
Notifications
You must be signed in to change notification settings - Fork 5
124 lines (108 loc) · 4.04 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
on:
push:
branches:
- main
name: release-please
jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v5
id: configure-changelog
with:
result-encoding: string
script: |
const changelogTypes = [
{type: "feat", section: "Features", hidden: false},
{type: "chore", section: "Misc", hidden: false},
{type: "fix", section: "BugFixes", hidden: false},
]
return JSON.stringify(changelogTypes)
# See https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow
# For why we need to generate a token and not use the default
- name: Generate token
id: generate_token
uses: chanzuckerberg/[email protected]
with:
app_id: ${{ secrets.CZI_RELEASE_PLEASE_APP_ID }}
private_key: ${{ secrets.CZI_RELEASE_PLEASE_PK }}
- name: release please
uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: simple
bump-minor-pre-major: true
changelog-types: ${{ steps.configure-changelog.outputs.result }}
token: ${{ steps.generate_token.outputs.token }}
- uses: actions/checkout@v3
# we need to fetch all history and tags,
# so we build the proper version
with:
fetch-depth: 0
if: ${{ steps.release.outputs.release_created }}
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
cache: true
if: ${{ steps.release.outputs.release_created }}
- name: Log in to Docker GitHub registry
run: |
docker login docker.pkg.github.com -u ${GITHUB_ACTOR} -p ${GITHUB_TOKEN}
env:
GITHUB_ACTOR: ${{ secrets.CZIBUILDBOT_USERNAME }}
GITHUB_TOKEN: ${{ secrets.CZIBUILDBOT_GITHUB_KEY }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
if: ${{ steps.release.outputs.release_created }}
outputs:
release_created: ${{ steps.release.outputs.release_created }}
# We create a prerelease whenever wo DONT create a release
prerelease:
runs-on: ubuntu-latest
if: ${{ !needs.release-please.outputs.release_created }}
needs:
- release-please
steps:
# See https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow
# For why we need to generate a token and not use the default
- name: Generate token
id: generate_token
uses: chanzuckerberg/[email protected]
with:
app_id: ${{ secrets.CZI_RELEASE_PLEASE_APP_ID }}
private_key: ${{ secrets.CZI_RELEASE_PLEASE_PK }}
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
cache: true
- name: Generate Version
id: generate_tag
run: |
set -eu
VERSION=v$(cat version.txt)-$(git rev-parse --short HEAD)
MESSAGE="Prerelease for ${VERSION}"
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git tag -a "${VERSION}" -m "${MESSAGE}"
git push origin "${VERSION}"
- name: Log in to Docker GitHub registry
run: |
docker login docker.pkg.github.com -u ${GITHUB_ACTOR} -p ${GITHUB_TOKEN}
env:
GITHUB_ACTOR: ${{ secrets.CZIBUILDBOT_USERNAME }}
GITHUB_TOKEN: ${{ secrets.CZIBUILDBOT_GITHUB_KEY }}
- name: Prerelease
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist -f .goreleaser.prerelease.yml
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}