Skip to content

Commit 0bed3a6

Browse files
refactor: split release job into independent jobs in separate
workflow - Extract release jobs from ci.yml to new release.yml workflow - Split monolithic release into 4 independent jobs (cargo, 2x npm, github) - Use workflow_call for explicit release triggering from CI - Enable parallel execution and individual job retry on failure
1 parent 1f374b1 commit 0bed3a6

File tree

3 files changed

+82
-40
lines changed

3 files changed

+82
-40
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ jobs:
154154
- name: Upload
155155
uses: actions/upload-artifact@v4
156156
with:
157-
name: package-${{ matrix.target.rust }}
157+
name: protofetch_${{ matrix.target.rust }}
158158
path: protofetch_${{ matrix.target.rust }}.tar.gz
159159

160160
test-npm-package:
@@ -255,44 +255,7 @@ jobs:
255255
fi
256256
257257
release:
258-
runs-on: ubuntu-latest
259258
if: github.repository == 'coralogix/protofetch' && startsWith(github.ref, 'refs/tags/')
260259
needs: [ package, test-npm-package ]
261-
env:
262-
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
263-
NPM_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
264-
265-
steps:
266-
- name: Checkout
267-
uses: actions/checkout@v3
268-
269-
- name: Publish cargo package
270-
run: cargo publish --token ${{ env.CRATES_IO_TOKEN }}
271-
272-
- name: Publish npm package (cx-protofetch)
273-
run: |
274-
node .github/npm/prepare-package.js --package cx-protofetch
275-
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ".npmrc"
276-
npm publish .github/npm/dist/cx-protofetch
277-
278-
- name: Publish npm package (@coralogix/protofetch)
279-
run: |
280-
node .github/npm/prepare-package.js --package coralogix-protofetch
281-
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ".npmrc"
282-
npm publish .github/npm/dist/coralogix-protofetch
283-
284-
- name: Download artifacts
285-
uses: actions/download-artifact@v4
286-
with:
287-
pattern: package-*
288-
merge-multiple: true
289-
290-
- name: Upload release artifacts
291-
uses: softprops/action-gh-release@v1
292-
with:
293-
files: |
294-
protofetch_aarch64-unknown-linux-musl.tar.gz
295-
protofetch_x86_64-unknown-linux-musl.tar.gz
296-
protofetch_aarch64-apple-darwin.tar.gz
297-
protofetch_x86_64-apple-darwin.tar.gz
298-
protofetch_x86_64-pc-windows-msvc.tar.gz
260+
uses: ./.github/workflows/release.yml
261+
secrets: inherit

.github/workflows/release.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
on:
2+
workflow_call:
3+
4+
name: Release
5+
6+
env:
7+
CARGO_TERM_COLOR: always
8+
9+
jobs:
10+
release-cargo:
11+
runs-on: ubuntu-latest
12+
if: github.repository == 'coralogix/protofetch'
13+
env:
14+
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Publish cargo package
21+
run: cargo publish --token ${{ env.CRATES_IO_TOKEN }}
22+
23+
release-npm-cx-protofetch:
24+
runs-on: ubuntu-latest
25+
if: github.repository == 'coralogix/protofetch'
26+
env:
27+
NPM_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
28+
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
33+
- name: Publish npm package (cx-protofetch)
34+
run: |
35+
node .github/npm/prepare-package.js --package cx-protofetch
36+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ".npmrc"
37+
npm publish .github/npm/dist/cx-protofetch
38+
39+
release-npm-coralogix-protofetch:
40+
runs-on: ubuntu-latest
41+
if: github.repository == 'coralogix/protofetch'
42+
env:
43+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
44+
45+
steps:
46+
- name: Checkout
47+
uses: actions/checkout@v4
48+
49+
- name: Publish npm package (@coralogix/protofetch)
50+
run: |
51+
node .github/npm/prepare-package.js --package coralogix-protofetch
52+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ".npmrc"
53+
npm publish .github/npm/dist/coralogix-protofetch
54+
55+
release-github:
56+
runs-on: ubuntu-latest
57+
if: github.repository == 'coralogix/protofetch'
58+
59+
steps:
60+
- name: Checkout
61+
uses: actions/checkout@v4
62+
63+
- name: Download artifacts
64+
uses: actions/download-artifact@v4
65+
with:
66+
pattern: package-*
67+
merge-multiple: true
68+
69+
- name: Upload release artifacts
70+
uses: softprops/action-gh-release@v1
71+
with:
72+
files: |
73+
protofetch_aarch64-unknown-linux-musl.tar.gz
74+
protofetch_x86_64-unknown-linux-musl.tar.gz
75+
protofetch_aarch64-apple-darwin.tar.gz
76+
protofetch_x86_64-apple-darwin.tar.gz
77+
protofetch_x86_64-pc-windows-msvc.tar.gz

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ target/
1616
*.pdb
1717

1818
# End of https://www.toptal.com/developers/gitignore/api/rust
19+
20+
.idea

0 commit comments

Comments
 (0)