Skip to content

Build, Upload, and Create GitHub Release #14

Build, Upload, and Create GitHub Release

Build, Upload, and Create GitHub Release #14

Workflow file for this run

name: Build, Upload, and Create GitHub Release
on:
push:
tags:
- "v*"
jobs:
test:
name: Test
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- run: cargo test
# build-and-release:
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# os: [ubuntu-latest, macos-latest, windows-latest]
# needs: test
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
#
# - name: Install Rust
# uses: actions-rs/toolchain@v1
# with:
# toolchain: stable
#
# - name: Build the project
# run: cargo build --release
#
# - name: Create GitHub Release
# uses: ncipollo/release-action@v1
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# tag_name: ${{ github.ref_name }}
# release_name: ${{ github.ref_name }}
# body: |
# This is a release for ${{ github.ref_name }}.
# See the changelog for details.
# draft: false
#
# - name: Upload Release Asset
# uses: actions/upload-release-asset@v1
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: target/${{matrix.os}}/release/checksum
# asset_name: checksum-${{ matrix.os }}
# asset_content_type: application/octet-stream
# on:
# push:
# branches:
# - main
#
# permissions:
# contents: write
#
# jobs:
build-and-release:
name: Build and upload
runs-on: ${{ matrix.os }}
needs: test
strategy:
matrix:
include:
- build: linux
os: ubuntu-22.04
target: x86_64-unknown-linux-musl
- build: macos
os: macos-latest
target: x86_64-apple-darwin
- build: macos
os: macos-latest
target: aarch64-apple-darwin
# - build: windows-gnu
# os: windows-latest
# target: x86_64-pc-windows-gnu
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get the release version from the tag
shell: bash
run: echo "VERSION=$(git describe --tags --always)" >> $GITHUB_ENV
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --verbose --release --target ${{ matrix.target }}
- name: Build archive
shell: bash
if: startsWith(github.ref, 'refs/tags/')
run: |
binary_name="checksum"
dirname="$binary_name-${{ env.VERSION }}-${{ matrix.target }}"
mkdir "$dirname"
if [ "${{ matrix.os }}" = "windows-latest" ]; then
mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname"
mv "target/${{ matrix.target }}/release/$binary_name" "$dirname"
if [ "${{ matrix.os }}" = "windows-latest" ]; then
7z a "$dirname.zip" "$dirname"
echo "ASSET=$dirname.zip" >> $GITHUB_ENV
tar -czf "$dirname.tar.gz" "$dirname"
echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
${{ env.ASSET }}