Release Binary Assets #11
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
name: Release Binary Assets | |
on: | |
release: | |
types: | |
- published | |
workflow_dispatch: | |
inputs: | |
tag-name: | |
description: "Tag name" | |
required: true | |
default: "v0.1.0" | |
jobs: | |
release: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- target: x86_64-unknown-linux-musl | |
os: ubuntu-latest | |
cross: false | |
binName: t-rec | |
- target: x86_64-apple-darwin | |
os: macos-latest | |
cross: false | |
binName: t-rec | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
target: ${{ matrix.target }} | |
override: true | |
- name: extract tag from event | |
if: github.event_name == 'release' | |
run: echo "TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV | |
- name: extract tag from input | |
if: github.event_name == 'workflow_dispatch' | |
run: echo "TAG=${{ github.event.inputs.tag-name }}" >> $GITHUB_ENV | |
- if: ${{ matrix.os == 'ubuntu-latest' }} | |
name: install libX11-devel for libX11 | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libx11-dev | |
- name: Build | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
use-cross: ${{ matrix.cross }} | |
args: --release --target=${{ matrix.target }} | |
- name: Smoke Test | |
uses: actions-rs/cargo@v1 | |
with: | |
command: run | |
use-cross: ${{ matrix.cross }} | |
args: --release --target=${{ matrix.target }} -- --help | |
- name: Create Archive | |
id: archive | |
shell: bash | |
env: | |
FILENAME: ${{ matrix.binName }}-${{ env.TAG }}-${{ matrix.target }}.tar.gz | |
run: | | |
tar -czvf "$FILENAME" README.md LICENSE -C "target/${{ matrix.target }}/release" "${{ matrix.binName }}" | |
echo "FILENAME=$FILENAME" >> $GITHUB_ENV | |
- name: Upload Archive | |
uses: ncipollo/[email protected] | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
allowUpdates: true | |
artifactErrorsFailBuild: true | |
artifacts: ${{ env.FILENAME }} | |
artifactContentType: application/octet-stream | |
omitBodyDuringUpdate: true | |
omitNameDuringUpdate: true | |
omitPrereleaseDuringUpdate: true | |
pkg-deb: | |
name: binary package .deb | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: build .deb file | |
env: | |
TARGET: x86_64-unknown-linux-musl | |
TAG: ${{ github.event.release.tag_name }} | |
uses: sassman/rust-deb-builder@v1 | |
- name: extract tag from event | |
if: github.event_name == 'release' | |
run: echo "TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV | |
- name: extract tag from input | |
if: github.event_name == 'workflow_dispatch' | |
run: echo "TAG=${{ github.event.inputs.tag-name }}" >> $GITHUB_ENV | |
- name: Archive deb artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: t-rec-${{ env.TAG }}-x86_64-unknown-linux-musl.deb | |
path: target/x86_64-unknown-linux-musl/debian/t-rec*.deb | |
- name: upload deb file | |
uses: ncipollo/[email protected] | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
allowUpdates: true | |
artifactErrorsFailBuild: true | |
artifacts: target/x86_64-unknown-linux-musl/debian/t-rec*.deb | |
artifactContentType: application/octet-stream | |
omitBodyDuringUpdate: true | |
omitNameDuringUpdate: true | |
omitPrereleaseDuringUpdate: true |