-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: build the artifacts and create the release in github actions (#41)
* feat: build the artifacts and create the release in github actions * fix: wrong indentation in the YAML file * fix: use a different command to calculate sha256 in macos * fix: use the right method to get the Sha256 checksum in Powershell * fix: run sha256sum only on Linux * chore: remove testing code
- Loading branch information
1 parent
0bf1ea0
commit 5bebef3
Showing
1 changed file
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
name: Build artifacts | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v[0-9]+.[0-9]+.[0-9]+" | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Test | ||
run: cargo test | ||
build: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
build: [linux, windows, macos] | ||
arch: [x86_64, aarch64] | ||
include: | ||
- build: linux | ||
arch: x86_64 | ||
os: ubuntu-latest | ||
platform: unknown-linux-musl | ||
cross: false | ||
name: linux-musl | ||
- build: linux | ||
arch: aarch64 | ||
os: ubuntu-latest | ||
platform: unknown-linux-musl | ||
cross: true | ||
name: linux-musl | ||
- build: windows | ||
arch: x86_64 | ||
os: windows-latest | ||
platform: pc-windows-msvc | ||
cross: false | ||
name: pc-windows | ||
- build: windows | ||
arch: aarch64 | ||
os: windows-latest | ||
platform: pc-windows-msvc | ||
cross: false | ||
name: pc-windows | ||
- build: macos | ||
arch: x86_64 | ||
os: macos-latest | ||
platform: apple-darwin | ||
cross: false | ||
name: macos-darwin | ||
- build: macos | ||
arch: aarch64 | ||
os: macos-latest | ||
platform: apple-darwin | ||
cross: false | ||
name: macos-darwin | ||
runs-on: ${{ matrix.os }} | ||
env: | ||
# This variable can be overriden with `cross` for builds that | ||
# requires it. By default, we will compile everything using cargo. | ||
CARGO: cargo | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install cross | ||
if: matrix.cross == true | ||
run: | | ||
cargo install cross | ||
echo "CARGO=cross" >> $GITHUB_ENV | ||
- name: Install target | ||
if: matrix.cross == false | ||
run: rustup target add ${{ matrix.arch }}-${{ matrix.platform }} | ||
- name: Install deps | ||
if: ${{ matrix.build == 'linux' }} | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install musl-tools | ||
- name: Build | ||
run: ${{env.CARGO}} build --verbose --release --target=${{ matrix.arch }}-${{ matrix.platform }} | ||
- name: Tarball | ||
shell: bash | ||
run: | | ||
mkdir out | ||
cp {README.md,LICENSE} out | ||
if [ "${{ matrix.os }}" = "windows-latest" ]; then | ||
cp "target/${{ matrix.arch }}-${{ matrix.platform }}/release/fu.exe" ./out | ||
else | ||
cp "target/${{ matrix.arch }}-${{ matrix.platform }}/release/fu" ./out | ||
fi | ||
tar czvf "fu-${{ matrix.name }}-${{ matrix.arch }}.tar.gz" -C ./out . | ||
echo "TARBALL=fu-${{ matrix.name }}-${{ matrix.arch }}.tar.gz" >> $GITHUB_ENV | ||
- name: Create the new release | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
gh release create --generate-notes ${{ github.ref_name }} || true | ||
- name: Append assets | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: gh release upload ${{ github.ref_name }} ${{ env.TARBALL }} | ||
- name: Generate asset digest (Linux) | ||
if: ${{ matrix.build == 'linux' }} | ||
run: sha256sum "${{ env.TARBALL }}" | sudo tee "${{ env.TARBALL }}.sha256sum" > /dev/null | ||
- name: Generate asset digest (MacOS) | ||
if: ${{ matrix.build == 'macos' }} | ||
run: shasum -a 256 "${{ env.TARBALL }}" | sudo tee "${{ env.TARBALL }}.sha256sum" > /dev/null | ||
- name: Generate asset digest (Windows) | ||
if: ${{ matrix.build == 'windows' }} | ||
run: Get-FileHash "${{ env.TARBALL }}" | Format-List -Property Algorithm,Hash > "${{ env.TARBALL }}.sha256sum" | ||
- name: Append release assets digests | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
gh release upload ${{ github.ref_name }} ${{ env.TARBALL }}.sha256sum |