Skip to content

Commit 747b327

Browse files
committed
ci: Refactor release pipeline
1 parent 31f8b35 commit 747b327

File tree

2 files changed

+73
-50
lines changed

2 files changed

+73
-50
lines changed

.github/workflows/release-crate.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 73 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Release (GitHub)
1+
name: Release
22
concurrency: release-git
33
on:
44
workflow_dispatch: { }
@@ -10,15 +10,20 @@ env:
1010
CARGO_INCREMENTAL: 0
1111

1212
jobs:
13-
git:
14-
name: Git release
13+
test:
14+
name: Test
15+
uses: ./.github/workflows/test.yml
16+
17+
bump:
18+
name: Bump version
19+
needs: [ test ]
1520
runs-on: ubuntu-latest
1621
environment: github
17-
permissions:
18-
contents: write
1922
outputs:
20-
issues-closed: ${{ steps.changelog.outputs.issues-closed }}
23+
commit: ${{ steps.last-commit.outputs.sha }}
24+
changelog: ${{ steps.changelog.outputs.changelog }}
2125
version: ${{ steps.changelog.outputs.version }}
26+
issues-closed: ${{ steps.changelog.outputs.issues-closed }}
2227
steps:
2328
- uses: actions/checkout@v4
2429
name: Checkout
@@ -44,35 +49,81 @@ jobs:
4449
with:
4550
release-type: ${{ steps.changelog.outputs.release-type }}
4651

47-
- name: Git release
48-
uses: alorel-actions/cargo/release-git@v2
52+
- name: Commit version bump
53+
run: |
54+
git commit -m "$(cat <<-END
55+
Bump version to ${{ steps.changelog.outputs.version }}
56+
57+
[ci skip]
58+
END
59+
)"
60+
61+
- name: Git tag
62+
run: git tag "${{ steps.changelog.outputs.version }}"
63+
64+
- name: Get last commit sha
65+
id: last-commit
66+
run: echo "sha=$(git log -n 1 --pretty=format:%H)" >> $GITHUB_OUTPUT
67+
68+
- name: Push commit
69+
run: git push
70+
71+
- name: Push tag
72+
run: git push --tags
73+
74+
release-cargo:
75+
name: Release (Cargo)
76+
needs: [ bump ]
77+
runs-on: ubuntu-latest
78+
environment: crates-io
79+
env:
80+
CARGO_INCREMENTAL: 0
81+
steps:
82+
- uses: actions/checkout@v4
83+
name: Checkout
84+
with:
85+
fetch-depth: 1
86+
ref: ${{ needs.bump.outputs.commit }}
87+
88+
- name: Init toolchain
89+
uses: alorel-actions/cargo/init@v2
4990
with:
50-
version: ${{ steps.changelog.outputs.version }}
51-
changelog: ${{ steps.changelog.outputs.changelog }}
52-
53-
notify:
54-
name: Notify closed issues
55-
needs:
56-
- git
57-
if: ${{ needs.git.outputs.issues-closed }}
91+
cache-prefix: release
92+
93+
- name: Publish crate
94+
run: cargo publish --locked --token ${{ secrets.CRATES_IO_TOKEN }}
95+
96+
release-github:
97+
name: Release (GitHub)
98+
needs: [ release-cargo, bump ]
5899
runs-on: ubuntu-latest
59-
environment: github
60100
permissions:
61101
contents: write
62102
steps:
63103
- uses: actions/checkout@v4
64104
name: Checkout
65105
with:
66-
token: ${{ secrets.GH_TOKEN }}
106+
fetch-depth: 1
107+
ref: ${{ needs.bump.outputs.commit }}
67108

68109
- name: Git identity
69110
uses: alorel-actions/git-ident@v1
70111

112+
- name: Create release
113+
uses: ncipollo/release-action@36e78ab6296394ce36f72f6488e68c2353b50514
114+
with:
115+
allowUpdates: false
116+
prerelease: false
117+
generateReleaseNotes: false
118+
commit: ${{ needs.bump.outputs.commit }}
119+
tag: ${{ needs.bump.outputs.version }}
120+
body: ${{ needs.bump.outputs.changelog }}
121+
71122
- name: Notify
72-
if: ${{ needs.git.outputs.issues-closed }}
123+
if: ${{ needs.bump.outputs.issues-closed }}
73124
uses: alorel-actions/semantic-release-lite/notify@v0
74125
with:
75-
tag: ${{ needs.git.outputs.version }}
76-
issues: ${{ needs.git.outputs.issues-closed }}
126+
tag: ${{ needs.bump.outputs.version }}
127+
issues: ${{ needs.bump.outputs.issues-closed }}
77128
allow-out-of-sync: true
78-
gh-token: ${{ secrets.GH_TOKEN }}
129+
gh-token: ${{ github.token }}

0 commit comments

Comments
 (0)