File tree Expand file tree Collapse file tree 2 files changed +75
-23
lines changed
Expand file tree Collapse file tree 2 files changed +75
-23
lines changed Original file line number Diff line number Diff line change 1+ name : Publish to crates.io
2+
3+ on :
4+ push :
5+ tags : ['v*']
6+
7+ jobs :
8+ test :
9+ runs-on : ubuntu-24.04
10+
11+ steps :
12+ - name : Print environment (debug)
13+ run : env
14+
15+ - name : Fetch sources
16+ uses : actions/checkout@v4
17+ with :
18+ submodules : recursive
19+
20+ - name : Run tests
21+ uses : frequenz-floss/gh-action-cargo-test@v1.0.0
22+
23+ create-github-release :
24+ needs : ["test"]
25+ name : Create GitHub release
26+ runs-on : ubuntu-24.04
27+ permissions :
28+ # We need write permissions on contents to create GitHub releases and on
29+ # discussions to create the release announcement in the discussion forums
30+ contents : write
31+ discussions : write
32+ steps :
33+ - name : Download RELEASE_NOTES.md
34+ run : |
35+ set -ux
36+ gh api \
37+ -X GET \
38+ -f ref=$REF \
39+ -H "Accept: application/vnd.github.raw" \
40+ "/repos/$REPOSITORY/contents/RELEASE_NOTES.md" \
41+ > RELEASE_NOTES.md
42+ env :
43+ REF : ${{ github.ref }}
44+ REPOSITORY : ${{ github.repository }}
45+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
46+
47+ - name : Create GitHub release
48+ run : |
49+ set -ux
50+ extra_opts=
51+ if echo "$REF_NAME" | grep -- -; then extra_opts=" --prerelease"; fi
52+ gh release create \
53+ -R "$REPOSITORY" \
54+ --notes-file RELEASE_NOTES.md \
55+ --generate-notes \
56+ $extra_opts \
57+ $REF_NAME
58+ env :
59+ REF_NAME : ${{ github.ref_name }}
60+ REPOSITORY : ${{ github.repository }}
61+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
62+
63+ publish :
64+ needs : ["create-github-release"]
65+ runs-on : ubuntu-24.04
66+ environment : release
67+ permissions :
68+ id-token : write
69+ steps :
70+ - uses : actions/checkout@v5
71+ - uses : rust-lang/crates-io-auth-action@b7e9a28eded4986ec6b1fa40eeee8f8f165559ec # v1.0.3
72+ id : auth
73+ - run : cargo publish
74+ env :
75+ CARGO_REGISTRY_TOKEN : ${{ steps.auth.outputs.token }}
Original file line number Diff line number Diff line change 2828
2929 - name : Run tests
3030 uses : frequenz-floss/gh-action-cargo-test@v1.0.0
31-
32- release :
33- runs-on : ubuntu-latest
34- if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
35- needs : [test]
36- steps :
37- - uses : actions/checkout@v5
38- - uses : actions/cache@v4
39- with :
40- path : ~/.cargo/registry
41- key : ' ${{ runner.os }}-cargo-registry-${{ hashFiles('' **/Cargo.lock'' ) }}'
42- - uses : actions/cache@v4
43- with :
44- path : ~/.cargo/git
45- key : ' ${{ runner.os }}-cargo-index-${{ hashFiles('' **/Cargo.lock'' ) }}'
46- - uses : actions/cache@v4
47- with :
48- path : target
49- key : ' ${{ runner.os }}-cargo-build-target-${{ hashFiles('' **/Cargo.lock'' ) }}'
50- - name : package
51- run : cargo package
52- - name : publish
53- run : cargo publish --token ${{ secrets.CRATES_TOKEN }}
You can’t perform that action at this time.
0 commit comments