44 pull_request :
55 types : [closed]
66 branches : [master]
7+ workflow_dispatch :
78
89permissions :
910 contents : read
2021 runs-on : ubuntu-latest
2122 # Run when PR with 'release' label is merged to master
2223 if : |
23- github.event.pull_request.merged == true
24- && contains(github.event.pull_request.labels.*.name, 'release')
24+ github.event_name == 'workflow_dispatch' ||
25+ (github.event_name == 'pull_request' &&
26+ github.event.pull_request.merged == true &&
27+ contains(github.event.pull_request.labels.*.name, 'release'))
2528 outputs :
2629 should-release : ${{ steps.check.outputs.should-release }}
2730 steps :
@@ -31,21 +34,13 @@ jobs:
3134 ref : master
3235 fetch-depth : 0
3336
34- - name : Install Rust
35- uses : dtolnay/rust-toolchain@0b1efabc08b657293548b77fb76cc02d26091c7e
36- with :
37- toolchain : 1.91.1
38- components : cargo
39-
40- - name : Install Sampo CLI
41- run : cargo install sampo
42-
4337 - name : Check release conditions
4438 id : check
4539 run : |
46- if sampo release --dry-run; then
40+ changeset_count=$(find .sampo/changesets -name '*.md' 2>/dev/null | wc -l)
41+ if [ "$changeset_count" -gt 0 ]; then
4742 echo "should-release=true" >> "$GITHUB_OUTPUT"
48- echo "Changesets found , ready to release"
43+ echo "Found $changeset_count changeset(s) , ready to release"
4944 else
5045 echo "should-release=false" >> "$GITHUB_OUTPUT"
5146 echo "No changesets to release"
@@ -109,10 +104,18 @@ jobs:
109104 - name : Install Rust
110105 uses : dtolnay/rust-toolchain@0b1efabc08b657293548b77fb76cc02d26091c7e
111106 with :
112- toolchain : 1.91.1
113- components : cargo
107+ toolchain : 1.91.1
108+ components : cargo
109+
110+ - name : Cache Sampo CLI
111+ id : cache-sampo
112+ uses : actions/cache@v3
113+ with :
114+ path : ~/.cargo/bin/sampo
115+ key : sampo-${{ runner.os }}-${{ runner.arch }}
114116
115117 - name : Install Sampo CLI
118+ if : steps.cache-sampo.outputs.cache-hit != 'true'
116119 run : cargo install sampo
117120
118121 - name : Install Hex dependencies
@@ -161,6 +164,12 @@ jobs:
161164 if : steps.commit-release.outputs.committed == 'true'
162165 run : git push origin --tags
163166
167+ - name : Create GitHub Release
168+ if : steps.commit-release.outputs.committed == 'true'
169+ env :
170+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
171+ run : gh release create "v${{ steps.sampo-release.outputs.new_version }}" --generate-notes
172+
164173 # Notify in case of a failure
165174 - name : Send failure event to PostHog
166175 if : ${{ failure() }}
0 commit comments