Skip to content

Commit 921a58f

Browse files
elopezanishnaik
andauthored
ci: automated release builds (#342)
* add M1 mac arch build and test * Update .github/workflows/ci.yml Co-authored-by: Emilio López <[email protected]> * Update .github/workflows/ci.yml Co-authored-by: Emilio López <[email protected]> * ci: automate release creation when pushing a tag * ci: upgrade actions/setup-{node,go} * ci: fix Python dependency installation on macOS error: externally-managed-environment × This environment is externally managed ╰─> To install Python packages system-wide, try brew install xyz, where xyz is the package you are trying to install. If you wish to install a non-brew-packaged Python package, create a virtual environment using python3 -m venv path/to/venv. Then use path/to/venv/bin/python and path/to/venv/bin/pip. If you wish to install a non-brew packaged Python application, it may be easiest to use pipx install xyz, which will manage a virtual environment for you. Make sure you have pipx installed. note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages. hint: See PEP 668 for the detailed specification. * ci: use `alls-green` to decide success status `release` can be skipped, but GitHub will then skip `all-checks`. We need to check that `release` is successful when it runs, but ignore it when it is skipped. --------- Co-authored-by: Anish Naik <[email protected]>
1 parent da2bcb6 commit 921a58f

File tree

1 file changed

+74
-16
lines changed

1 file changed

+74
-16
lines changed

.github/workflows/ci.yml

Lines changed: 74 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
push:
66
branches:
77
- master
8+
tags:
9+
- "v*"
810
pull_request:
911
branches:
1012
- master
@@ -22,7 +24,10 @@ jobs:
2224
needs: [lint, test]
2325
strategy:
2426
matrix:
25-
environment: [ubuntu-latest, macos-latest, windows-latest]
27+
environment: [ubuntu-latest, macos-12, macos-14, windows-latest]
28+
permissions:
29+
contents: read
30+
id-token: write
2631

2732
runs-on: ${{ matrix.environment }}
2833
timeout-minutes: 10
@@ -44,32 +49,76 @@ jobs:
4449
printf 'TEMP=%s\\tmpdir\n' "$DIR" | tee -a "$GITHUB_ENV"
4550
go env
4651
47-
- uses: actions/setup-go@v4
52+
- uses: actions/setup-go@v5
4853
with:
4954
go-version: "^1.18.1"
55+
# disable caching during release (tag) builds
56+
cache: ${{ !startsWith(github.ref, 'refs/tags/') }}
5057

5158
- name: Build (Linux and macOS)
5259
if: runner.os == 'Linux' || runner.os == 'macOS'
5360
run: go build -o medusa -v .
5461

5562
- name: Compress (Linux and macOS)
5663
if: runner.os == 'Linux' || runner.os == 'macOS'
57-
run: tar -czvf medusa.tar.gz medusa
64+
run: tar -czvf medusa-${{ runner.os }}-${{ runner.arch }}.tar.gz medusa
5865

5966
- name: Build (Windows)
6067
if: runner.os == 'Windows'
6168
run: go build -o medusa.exe -v .
6269

6370
- name: Compress (Windows)
6471
if: runner.os == 'Windows'
65-
run: tar -czvf medusa.tar.gz medusa.exe
72+
run: tar -czvf medusa-${{ runner.os }}-${{ runner.arch }}.tar.gz medusa.exe
6673

67-
- name: Upload artifact on merge to master
68-
if: github.ref == 'refs/heads/master'
69-
uses: actions/upload-artifact@v3
74+
- name: Rename for release
75+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
76+
shell: bash
77+
run: |
78+
[ ! -f medusa-Linux-X64.tar.gz ] || mv medusa-Linux-X64.tar.gz medusa-linux-x64.tar.gz
79+
[ ! -f medusa-macOS-X64.tar.gz ] || mv medusa-macOS-X64.tar.gz medusa-mac-x64.tar.gz
80+
[ ! -f medusa-macOS-ARM64.tar.gz ] || mv medusa-macOS-ARM64.tar.gz medusa-mac-arm64.tar.gz
81+
[ ! -f medusa-Windows-X64.tar.gz ] || mv medusa-Windows-X64.tar.gz medusa-win-x64.tar.gz
82+
83+
- name: Sign artifact
84+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
85+
uses: sigstore/[email protected]
86+
with:
87+
inputs: ./medusa-*.tar.gz
88+
89+
- name: Upload artifact
90+
if: github.ref == 'refs/heads/master' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
91+
uses: actions/upload-artifact@v4
7092
with:
71-
name: medusa-${{ runner.os }}
72-
path: medusa.tar.gz
93+
name: medusa-${{ runner.os }}-${{ runner.arch }}
94+
path: |
95+
./medusa-*.tar.gz
96+
./medusa-*.tar.gz.sigstore
97+
98+
release:
99+
needs: [build]
100+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
101+
permissions:
102+
contents: write
103+
104+
runs-on: ubuntu-latest
105+
timeout-minutes: 10
106+
107+
steps:
108+
- name: Download binaries
109+
uses: actions/download-artifact@v4
110+
with:
111+
pattern: medusa-*
112+
merge-multiple: true
113+
114+
- name: Create GitHub release and upload binaries
115+
uses: softprops/action-gh-release@9d7c94cfd0a1f3ed45544c887983e9fa900f0564 # v2.0.4
116+
with:
117+
draft: true
118+
name: "${{ github.ref_name }}"
119+
files: |
120+
./medusa-*.tar.gz
121+
./medusa-*.tar.gz.sigstore
73122
74123
lint:
75124
runs-on: ubuntu-latest
@@ -78,7 +127,7 @@ jobs:
78127
steps:
79128
- uses: actions/checkout@v4
80129

81-
- uses: actions/setup-go@v4
130+
- uses: actions/setup-go@v5
82131
with:
83132
go-version: "^1.18.1"
84133

@@ -110,14 +159,18 @@ jobs:
110159
test:
111160
strategy:
112161
matrix:
113-
environment: [ubuntu-latest, macos-latest, windows-latest]
162+
environment: [ubuntu-latest, macos-12, macos-14, windows-latest]
114163

115164
runs-on: ${{ matrix.environment }}
116165
timeout-minutes: 20
117166

118167
steps:
119168
- uses: actions/checkout@v4
120169

170+
- uses: actions/setup-python@v5
171+
with:
172+
python-version: "3.10"
173+
121174
- name: Speed up Go, Python, Node (Windows)
122175
if: runner.os == 'Windows'
123176
run: |
@@ -142,11 +195,11 @@ jobs:
142195
npm config set cache "$DIR\\npm-cache" --global
143196
echo "::endgroup::"
144197
145-
- uses: actions/setup-go@v4
198+
- uses: actions/setup-go@v5
146199
with:
147200
go-version: "^1.18.1"
148201

149-
- uses: actions/setup-node@v3
202+
- uses: actions/setup-node@v4
150203
with:
151204
node-version: 18.15
152205

@@ -155,7 +208,7 @@ jobs:
155208

156209
- name: Install Python dependencies
157210
run: |
158-
pip3 install --no-cache-dir setuptools solc-select crytic-compile
211+
pip3 install --no-cache-dir solc-select crytic-compile
159212
160213
- name: Install solc
161214
run: |
@@ -165,9 +218,14 @@ jobs:
165218
run: go test ./...
166219

167220
all-checks:
168-
needs: [lint, test, build]
221+
if: always()
222+
needs: [lint, test, build, release]
169223

170224
runs-on: ubuntu-latest
171225

172226
steps:
173-
- run: true
227+
- name: Decide whether the needed jobs succeeded or failed
228+
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
229+
with:
230+
allowed-skips: release
231+
jobs: ${{ toJSON(needs) }}

0 commit comments

Comments
 (0)