Skip to content

Commit a317141

Browse files
authored
fix(ci): Update release workflow to use pre-generated artifacts. (#61)
1 parent fa15827 commit a317141

File tree

1 file changed

+89
-31
lines changed

1 file changed

+89
-31
lines changed

.github/workflows/release.yml

Lines changed: 89 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ env:
1313
CI: "true"
1414

1515
jobs:
16-
release:
16+
release_github:
1717
runs-on: ubuntu-latest
1818
permissions:
1919
contents: write
@@ -59,6 +59,14 @@ jobs:
5959
run: npx projen install:ci
6060
- name: release
6161
run: npx projen release
62+
- name: Backup artifact permissions
63+
run: cd dist && getfacl -R . > permissions-backup.acl
64+
continue-on-error: true
65+
- name: Upload artifacts
66+
uses: actions/upload-artifact@v3
67+
with:
68+
name: build-artifact
69+
path: dist
6270
- name: Release GitHub
6371
env:
6472
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -67,20 +75,30 @@ jobs:
6775
run: errout=$(mktemp); gh release create $(cat dist/releasetag.txt) -R $GITHUB_REPOSITORY -F dist/changelog.md -t $(cat dist/releasetag.txt) --target $GITHUB_REF 2> $errout && true; exitcode=$?; if [ $exitcode -ne 0 ] && ! grep -q "Release.tag_name already exists" $errout; then cat $errout; exit $exitcode; fi
6876
release_npm:
6977
name: Publish to npm
70-
needs: release
78+
needs: release_github
7179
runs-on: ubuntu-latest
7280
permissions:
73-
contents: write
81+
contents: read
7482
steps:
75-
- name: Checkout
76-
uses: actions/checkout@v4
7783
- uses: actions/setup-node@v4
7884
with:
7985
node-version: 20.x
86+
- name: Download build artifacts
87+
uses: actions/download-artifact@v3
88+
with:
89+
name: build-artifact
90+
path: dist
91+
- name: Restore build artifact permissions
92+
run: cd dist && setfacl --restore=permissions-backup.acl
93+
continue-on-error: true
94+
- name: Prepare Repository
95+
run: mv dist .repo
8096
- name: Install Dependencies
81-
run: cd npx projen install:ci
97+
run: cd .repo && npx projen install:ci
8298
- name: Create JS artifact
83-
run: npx projen package:js
99+
run: cd .repo && npx projen package:js
100+
- name: Collect js Artifact
101+
run: mv .repo/dist dist
84102
- name: Release JS Artifact
85103
env:
86104
NPM_DIST_TAG: latest
@@ -89,24 +107,34 @@ jobs:
89107
run: npx -p publib@latest publib-npm
90108
release_maven:
91109
name: Publish to Maven Central
92-
needs: release
110+
needs: release_github
93111
runs-on: ubuntu-latest
94112
permissions:
95-
contents: write
113+
contents: read
96114
steps:
97-
- name: Checkout
98-
uses: actions/checkout@v4
99115
- uses: actions/setup-java@v4
100116
with:
101117
distribution: temurin
102118
java-version: '17.x'
103119
- uses: actions/setup-node@v4
104120
with:
105121
node-version: 20.x
122+
- name: Download build artifacts
123+
uses: actions/download-artifact@v3
124+
with:
125+
name: build-artifact
126+
path: dist
127+
- name: Restore build artifact permissions
128+
run: cd dist && setfacl --restore=permissions-backup.acl
129+
continue-on-error: true
130+
- name: Prepare Repository
131+
run: mv dist .repo
106132
- name: Install Dependencies
107-
run: npx projen install:ci
133+
run: cd .repo && npx projen install:ci
108134
- name: Create java artifact
109-
run: npx projen package:java
135+
run: cd .repo && npx projen package:java
136+
- name: Collect java Artifact
137+
run: mv .repo/dist dist
110138
- name: Release
111139
env:
112140
MAVEN_SERVER_ID: 'github'
@@ -117,70 +145,100 @@ jobs:
117145
run: npx -p publib@latest publib-maven
118146
release_pypi:
119147
name: Publish to PyPI
120-
needs: release
148+
needs: release_github
121149
runs-on: ubuntu-latest
122150
permissions:
123-
contents: write
151+
contents: read
124152
steps:
125-
- name: Checkout
126-
uses: actions/checkout@v4
127153
- uses: actions/setup-node@v4
128154
with:
129155
node-version: 20.x
130156
- uses: actions/setup-python@v5
131157
with:
132158
python-version: 3.12.3
159+
- name: Download build artifacts
160+
uses: actions/download-artifact@v3
161+
with:
162+
name: build-artifact
163+
path: dist
164+
- name: Restore build artifact permissions
165+
run: cd dist && setfacl --restore=permissions-backup.acl
166+
continue-on-error: true
167+
- name: Prepare Repository
168+
run: mv dist .repo
133169
- name: Install Dependencies
134-
run: npx projen install:ci
170+
run: cd .repo && npx projen install:ci
135171
- name: Create python artifact
136-
run: npx projen package:python
172+
run: cd .repo && npx projen package:python
173+
- name: Collect python Artifact
174+
run: mv .repo/dist dist
137175
- name: Release
138176
env:
139177
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
140178
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
141179
run: npx -p publib@latest publib-pypi
142180
release_nuget:
143181
name: Publish to NuGet Gallery
144-
needs: release
182+
needs: release_github
145183
runs-on: ubuntu-latest
146184
permissions:
147-
contents: write
185+
contents: read
148186
steps:
149-
- name: Checkout
150-
uses: actions/checkout@v4
151187
- uses: actions/setup-node@v4
152188
with:
153189
node-version: 20.x
154190
- uses: actions/setup-dotnet@v4
155191
with:
156192
dotnet-version: 3.x
193+
- name: Download build artifacts
194+
uses: actions/download-artifact@v3
195+
with:
196+
name: build-artifact
197+
path: dist
198+
- name: Restore build artifact permissions
199+
run: cd dist && setfacl --restore=permissions-backup.acl
200+
continue-on-error: true
201+
- name: Prepare Repository
202+
run: mv dist .repo
157203
- name: Install Dependencies
158-
run: npx projen install:ci
204+
run: cd .repo && npx projen install:ci
159205
- name: Create dotnet artifact
160-
run: npx projen package:dotnet
206+
run: cd .repo && npx projen package:dotnet
207+
- name: Collect dotnet Artifact
208+
run: mv .repo/dist dist
161209
- name: Release
162210
env:
163211
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
164212
run: npx -p publib@latest publib-nuget
165213
release_golang:
166214
name: Publish to GitHub Go Module Repository
167-
needs: release
215+
needs: release_github
168216
runs-on: ubuntu-latest
169217
permissions:
170-
contents: write
218+
contents: read
171219
steps:
172-
- name: Checkout
173-
uses: actions/checkout@v4
174220
- uses: actions/setup-node@v4
175221
with:
176222
node-version: 20.x
177223
- uses: actions/setup-go@v4
178224
with:
179225
go-version: ^1.16.0
226+
- name: Download build artifacts
227+
uses: actions/download-artifact@v3
228+
with:
229+
name: build-artifact
230+
path: dist
231+
- name: Restore build artifact permissions
232+
run: cd dist && setfacl --restore=permissions-backup.acl
233+
continue-on-error: true
234+
- name: Prepare Repository
235+
run: mv dist .repo
180236
- name: Install Dependencies
181-
run: npx projen install:ci
237+
run: cd .repo && npx projen install:ci
182238
- name: Create go artifact
183-
run: npx projen package:go
239+
run: cd .repo && npx projen package:go
240+
- name: Collect go Artifact
241+
run: mv .repo/dist dist
184242
- name: Release
185243
env:
186244
GIT_USER_NAME: github-actions

0 commit comments

Comments
 (0)