Skip to content

Commit 6810669

Browse files
committed
ci: add GitHub Actions workflow for automated releases
Added a new GitHub Actions workflow to automate the release process when tags matching "v*.*.*" are pushed or triggered manually via workflow dispatch. The workflow performs the following steps: 1. Creates a GitHub Release based on the tag name. 2. Builds release binaries for multiple target architectures (Linux musl x64, Linux musl aarch64, macOS x64, macOS aarch64). 3. Strips binary symbols for Linux builds to reduce size. 4. Generates SHA-256 checksums for each binary. 5. Packages the binaries and checksums into tar.gz files. 6. Uploads the release artifacts (binaries and checksums) to the created GitHub Release. Signed-off-by: Marcelo Borges <[email protected]>
1 parent 5b552c0 commit 6810669

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed

.github/workflows/release.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
workflow_dispatch:
8+
9+
jobs:
10+
create-release:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
upload_url: ${{ steps.create_release.outputs.upload_url }}
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v3
17+
18+
- name: Create GitHub Release
19+
id: create_release
20+
uses: actions/create-release@v1
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
with:
24+
tag_name: ${{ github.ref }}
25+
release_name: Release ${{ github.ref }}
26+
draft: false
27+
prerelease: false
28+
29+
build-release:
30+
needs: create-release
31+
runs-on: ${{ matrix.os }}
32+
strategy:
33+
matrix:
34+
build:
35+
- linux musl x64
36+
- linux musl aarch64
37+
- macos x64
38+
- macos aarch64
39+
include:
40+
- build: linux musl x64
41+
os: ubuntu-latest
42+
target: x86_64-unknown-linux-musl
43+
- build: linux musl aarch64
44+
os: ubuntu-latest
45+
target: aarch64-unknown-linux-musl
46+
- build: macos x64
47+
os: macos-latest
48+
target: x86_64-apple-darwin
49+
- build: macos aarch64
50+
os: macos-latest
51+
target: aarch64-apple-darwin
52+
steps:
53+
- name: Checkout repository
54+
uses: actions/checkout@v3
55+
56+
- name: Install dependencies (Linux only)
57+
if: matrix.os == 'ubuntu-latest'
58+
run: sudo apt-get install -y --no-install-recommends musl-tools
59+
60+
- name: Install Rust
61+
uses: actions-rust-lang/setup-rust-toolchain@v1
62+
with:
63+
toolchain: stable
64+
target: ${{ matrix.target }}
65+
66+
- name: Build release binary
67+
run: cargo build --release --target=${{ matrix.target }}
68+
69+
- name: Strip binary (Linux only)
70+
if: matrix.os == 'ubuntu-latest'
71+
run: strip target/${{ matrix.target }}/release/fswatcher
72+
73+
- name: Create checksum
74+
run: |
75+
cd target/${{ matrix.target }}/release
76+
sha256sum fswatcher > my_project-${{ matrix.target }}.sha256sum
77+
78+
- name: Tar release
79+
run: |
80+
cd target/${{ matrix.target }}/release
81+
tar -czvf fswatcher-${{ matrix.target }}.tar.gz my_project
82+
83+
- name: Upload release artifact
84+
uses: actions/upload-release-asset@v1
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87+
with:
88+
upload_url: ${{ needs.create-release.outputs.upload_url }}
89+
asset_path: target/${{ matrix.target }}/release/fswatcher-${{ matrix.target }}.tar.gz
90+
asset_name: fswatcher-${{ matrix.target }}.tar.gz
91+
asset_content_type: application/octet-stream
92+
93+
- name: Upload checksum
94+
uses: actions/upload-release-asset@v1
95+
env:
96+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
97+
with:
98+
upload_url: ${{ needs.create-release.outputs.upload_url }}
99+
asset_path: target/${{ matrix.target }}/release/fswatcher-${{ matrix.target }}.sha256sum
100+
asset_name: fswatcher-${{ matrix.target }}.sha256sum
101+
asset_content_type: text/plain

0 commit comments

Comments
 (0)