Skip to content

Commit 7ef69c5

Browse files
committed
Refactor GitHub Actions workflow to include building and uploading binaries
1 parent 8a61ccd commit 7ef69c5

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

.github/workflows/publish.yaml

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish to crate.io
1+
name: Publish to crate.io and GitHub Release
22

33
on:
44
workflow_call:
@@ -8,7 +8,27 @@ on:
88
type: string
99

1010
jobs:
11+
build:
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest, windows-latest, macos-latest]
15+
runs-on: ${{ matrix.os }}
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Install Rust Toolchain
19+
uses: actions-rs/toolchain@v1
20+
with:
21+
toolchain: stable
22+
- name: Build Binary
23+
run: cargo build --release
24+
- name: Upload Binary
25+
uses: actions/upload-artifact@v3
26+
with:
27+
name: binary-${{ matrix.os }}
28+
path: target/release/${{ github.event.repository.name }}${{ matrix.os == 'windows-latest' && '.exe' || '' }}
29+
1130
publish:
31+
needs: build
1232
runs-on: ubuntu-latest
1333
steps:
1434
- uses: actions/checkout@v4
@@ -28,16 +48,20 @@ jobs:
2848
run: |
2949
cargo login ${CARGO_REGISTRY_TOKEN}
3050
cargo publish
31-
- name: Create Git Tag
51+
- name: Download Binaries
52+
uses: actions/download-artifact@v3
53+
- name: Rename Binaries
3254
run: |
33-
git config user.name github-actions
34-
git config user.email [email protected]
35-
git tag -a v${{ inputs.version }} -m "Release ${{ inputs.version }}"
36-
git push origin v${{ inputs.version }}
55+
mv binary-ubuntu-latest/${{ github.event.repository.name }} ${{ github.event.repository.name }}-linux
56+
mv binary-windows-latest/${{ github.event.repository.name }}.exe ${{ github.event.repository.name }}-windows.exe
57+
mv binary-macos-latest/${{ github.event.repository.name }} ${{ github.event.repository.name }}-macos
3758
- name: Create GitHub Release
3859
env:
3960
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4061
run: |
4162
gh release create v${{ inputs.version }} \
4263
--title "Release ${{ inputs.version }}" \
43-
--generate-notes
64+
--generate-notes \
65+
${{ github.event.repository.name }}-linux \
66+
${{ github.event.repository.name }}-windows.exe \
67+
${{ github.event.repository.name }}-macos

0 commit comments

Comments
 (0)