forked from berty/berty
-
Notifications
You must be signed in to change notification settings - Fork 0
232 lines (202 loc) · 7.65 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
name: Release
on:
push:
branches:
- master
pull_request:
paths:
# Go
- "go/**"
- "!go/**.md"
- ".goreleaser"
- "go.*"
- "**.go"
# CI
- ".github/workflows/release.yml"
- "tool/publish-npm-package"
# NPM package
- "./js/packages/api"
jobs:
semantic-release:
name: Semantic release
runs-on: ubuntu-latest
outputs:
new-release-published: ${{ steps.semantic-echo.outputs.new-release-published }}
release-version: ${{ steps.semantic-echo.outputs.release-version }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Unshallow
run: git fetch --prune --unshallow
- name: Run Semantic Release
id: semantic
uses: docker://ghcr.io/codfish/semantic-release-action:v1
with:
branches: |
['master']
plugins: |
[
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
'@semantic-release/github'
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Export Semantic Release
id: semantic-echo
run: |
echo "::set-output name=new-release-published::${{steps.semantic.outputs.new-release-published}}"
echo "::set-output name=release-version::${{steps.semantic.outputs.release-version}}"
release-on-stores:
name: Release on stores
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup asdf
uses: asdf-vm/actions/setup@v1
- name: Setup jq
run: |
asdf plugin add jq
asdf install jq
- name: Get last commit message
env:
EVENT: ${{ toJson(github.event) }}
run: |
echo "$EVENT" > $RUNNER_TEMP/event
echo "commit_message=$(jq '.
| select(.commits != null)
| .after as $last_commit
| .commits
| map(select(.id == $last_commit))[0].message' $RUNNER_TEMP/event)" >> $GITHUB_ENV
- name: Dispatch event to release repo
uses: actions/github-script@v6
with:
github-token: ${{ secrets.REPOSITORY_DISPATCH }}
script: |
await github.rest.repos.createDispatchEvent({
owner: 'berty',
repo: 'release-on-stores',
event_type: 'release',
client_payload: {"commit_message":${{ env.commit_message }}},
})
post-semantic-release:
needs: semantic-release
#if: needs.semantic-release.outputs.new-release-published == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Unshallow
run: git fetch --prune --unshallow
- name: Setup asdf
uses: asdf-vm/actions/setup@v1
- name: Setup go
run: |
asdf plugin add golang
asdf install golang
- name: Setup node
if: needs.semantic-release.outputs.new-release-published == 'true'
run: |
asdf plugin add nodejs
asdf install nodejs
- name: "Publish npm package: @berty/api (Real)"
if: needs.semantic-release.outputs.new-release-published == 'true'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
continue-on-error: true
working-directory: tool/publish-npm-package
run: go run . -path=../../js/packages/api -version=${{ needs.semantic-release.outputs.release-version }}
# Next step also sets up a .npmrc file for automatic publishing to npm
- name: "Publish npm package: @berty/api (DryRun)"
if: needs.semantic-release.outputs.new-release-published != 'true'
working-directory: tool/publish-npm-package
run: go run . -path=../../js/packages/api -version=0.0.0 -dry-run
- name: Register version on pkg.go.dev
if: needs.semantic-release.outputs.new-release-published == 'true'
run: |
package=$(cat go.mod | grep ^module | awk '{print $2}')
version=v${{ needs.semantic-release.outputs.release-version }}
url=https://proxy.golang.org/${package}/@v/${version}.info
set -x +e
curl -i $url
build-asset:
needs: semantic-release
name: build asset
runs-on: ${{ matrix.config.runs-on }}
strategy:
matrix:
config: [
# @FIXME(gfanton): latest ubuntu version broke `Install Linux Dependencies` step
{ runs-on: "ubuntu-20.04", goos: "linux" },
{ runs-on: "macos-latest", goos: "darwin" },
{ runs-on: "windows-latest", goos: "windows" },
# TODO: bertyguy
]
env:
OSXCROSS_DIR: /home/runner/work/osxcross
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Unshallow
run: git fetch --prune --unshallow
- name: Load variables from file
uses: antifree/[email protected]
with:
filename: .github/workflows/utils/variables.json
- name: Setup asdf (Posix)
if: matrix.config.goos != 'windows'
uses: asdf-vm/actions/setup@v1
- name: Setup go (Posix)
if: matrix.config.goos != 'windows'
run: |
asdf plugin add golang
asdf install golang
echo "go_version=$(asdf current golang | xargs | cut -d ' ' -f 2)" >> $GITHUB_ENV
- name: Get go version (Windows)
if: matrix.config.goos == 'windows'
shell: bash
run: echo "go_version=$(cat .tool-versions | grep '^golang [0-9]\+\.[0-9]\+\.[0-9]\+.*$' | cut -d ' ' -f 2)" >> $GITHUB_ENV
- name: Setup go (Windows)
if: matrix.config.goos == 'windows'
uses: actions/setup-go@v3
with:
go-version: ${{ env.go_version }}
- name: Cache go modules
uses: actions/[email protected]
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ env.go_version }}-${{ env.json_cache-versions_go }}-${{ hashFiles('go/**/go.sum') }}
restore-keys: ${{ runner.os }}-go-${{ env.go_version }}-${{ env.json_cache-versions_go }}-
- name: Install Linux Dependencies
if: matrix.config.goos == 'linux'
run: |
echo 'deb http://security.ubuntu.com/ubuntu bionic-security main' | sudo tee -a /etc/apt/sources.list
sudo apt update
sudo apt-cache policy libssl1.0-dev
sudo apt install -f libssl1.0-dev
sudo apt install -f gcc-multilib g++-multilib gcc-mingw-w64 clang
sudo apt install -f -y libgl1-mesa-glx libgl1-mesa-dev xorg-dev
mkdir ../../osxcross
git clone https://github.com/plentico/osxcross-target.git ../../osxcross/target
- name: Run GoReleaser (DryRun)
uses: goreleaser/goreleaser-action@v3
if: needs.semantic-release.outputs.new-release-published != 'true'
with:
version: latest
args: release --clean -f .github/workflows/utils/.goreleaser.${{ matrix.config.goos }}.yml --skip=publish
- name: Run GoReleaser (Publish)
uses: goreleaser/goreleaser-action@v3
if: needs.semantic-release.outputs.new-release-published == 'true'
with:
version: latest
args: release --clean -f .github/workflows/utils/.goreleaser.${{ matrix.config.goos }}.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Dist/ directory listing (Posix)
if: matrix.config.goos != 'windows'
run: ls -lah dist
- name: Dist/ directory listing (Windows)
if: matrix.config.goos == 'windows'
run: Get-ChildItem -Recurse dist