Skip to content

Release v0.8.0 (#101) #35

Release v0.8.0 (#101)

Release v0.8.0 (#101) #35

Workflow file for this run

name: Release
on:
push:
tags: ['v*']
# Support running this manually without uploading to test out the workflow.
workflow_dispatch:
inputs:
version:
description: "Version we're pretending to release, e.g. 0.6.0"
required: true
type: string
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
# Linux
- slug: linux-amd64
target: x86_64-unknown-linux-musl
os: ubuntu-latest
strip: x86_64-linux-musl-strip
- slug: linux-arm64
target: aarch64-unknown-linux-gnu
os: ubuntu-latest
strip: aarch64-linux-gnu-strip
no-build-std: true
- slug: linux-armv7
target: armv7-unknown-linux-musleabihf
os: ubuntu-latest
strip: arm-linux-musleabihf-strip
no-build-std: true
# macOS
- slug: darwin-amd64
target: x86_64-apple-darwin
os: macos-latest
- slug: darwin-arm64
target: aarch64-apple-darwin
os: macos-latest
env:
CARGO: cargo
CROSS_VERSION: v0.2.5
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Determine toolchain
id: rust-toolchain
run: |
echo "value=$(cat rust-toolchain)" >> "$GITHUB_OUTPUT"
- name: Setup Rust
run: |
if ! command -v rustup &>/dev/null; then
curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused --location --silent --show-error --fail "https://sh.rustup.rs" | sh -s -- --default-toolchain none -y
echo "$CARGO_HOME/bin" >> "$GITHUB_PATH"
fi
rustup toolchain install ${{ steps.rust-toolchain.outputs.value }} \
--target ${{ matrix.target }} \
--component rust-src \
--profile minimal \
--no-self-update
- uses: Swatinem/rust-cache@v2
- name: Install Cross
if: matrix.os == 'ubuntu-latest' && matrix.target != ''
run: |
dir="$RUNNER_TEMP/cross-download"
mkdir "$dir"
echo "$dir" >> "$GITHUB_PATH"
cd "$dir"
curl -LO "https://github.com/cross-rs/cross/releases/download/$CROSS_VERSION/cross-x86_64-unknown-linux-musl.tar.gz"
tar xf cross-x86_64-unknown-linux-musl.tar.gz
echo "CARGO=cross" >> "$GITHUB_ENV"
- name: Build (build-std)
if: ${{ !matrix.no-build-std }}
run: |
${{ env.CARGO }} build \
--target ${{ matrix.target }} \
--locked \
--release \
-Z build-std=std,panic_abort \
-Z build-std-features=panic_immediate_abort
- name: Build (no-build-std)
if: ${{ matrix.no-build-std }}
run: |
${{ env.CARGO }} build \
--target ${{ matrix.target }} \
--locked \
--release
- name: Strip release binary (macos)
if: matrix.os == 'macos-latest'
run: |
strip=${{ matrix.strip || 'strip' }}
exe=target/${{ matrix.target }}/release/restack
echo "Before: $(wc -c < "$exe") bytes"
"$strip" target/${{ matrix.target }}/release/restack
echo "After: $(wc -c < "$exe") bytes"
- name: Strip release binary (cross)
if: env.CARGO == 'cross'
shell: bash
run: |
docker run --rm -v \
"$PWD/target:/target:Z" \
"ghcr.io/cross-rs/${{ matrix.target }}:main" \
"${{ matrix.strip }}" \
"/target/${{ matrix.target }}/release/restack"
- name: Prepare archive
run: |
tar -cvzf restack-${{ matrix.slug }}.tar.gz \
-C target/${{ matrix.target }}/release \
restack
- name: Upload archive
uses: actions/upload-artifact@v4
with:
name: restack-${{ matrix.slug }}
path: restack-*.tar.gz
release:
name: Release
runs-on: ubuntu-latest
needs: build
steps:
- name: Install parse-changelog
uses: taiki-e/install-action@v2
with:
tool: [email protected]
- name: Checkout code
uses: actions/checkout@v4
- name: Determine toolchain
id: rust-toolchain
run: |
echo "value=$(cat rust-toolchain)" >> "$GITHUB_OUTPUT"
- name: Checkout Homebrew tap
uses: actions/checkout@v4
with:
repository: abhinav/homebrew-tap
token: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
path: homebrew-tap
- name: Setup Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ steps.rust-toolchain.outputs.value }}
- name: Download archives
uses: actions/download-artifact@v4
with:
path: .
pattern: restack-*
merge-multiple: true
- name: Determine version number (push)
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
run: |
echo "VERSION=${REF#refs/tags/v}" >> "$GITHUB_ENV"
env:
REF: ${{ github.ref }}
- name: Determine version number (workflow_dispatch)
if: github.event_name == 'workflow_dispatch'
run: |
echo "VERSION=${INPUT_VERSION#v}" >> "$GITHUB_ENV"
env:
INPUT_VERSION: ${{ inputs.version }}
- name: Generate package specs
run: |
tools/release/genpkgspec.sh ${{ env.VERSION }} restack-*.tar.gz
echo ::group::Homebrew Formula
cat target/formula/restack.rb
echo ::endgroup::
echo ::group::restack-bin/PKGBUILD
cat target/aur-bin/PKGBUILD
echo ::endgroup::
- name: Extract changelog
run: |
parse-changelog CHANGELOG.md ${{ env.VERSION }} > ${{ github.workspace }}-CHANGELOG.txt
echo ::group::CHANGELOG
cat ${{ github.workspace }}-CHANGELOG.txt
echo ::endgroup::
- name: Publish Release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
files: 'restack-*.tar.gz'
body_path: ${{ github.workspace }}-CHANGELOG.txt
token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish Homebrew tap
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
working-directory: homebrew-tap
run: |
git config --local user.name "$COMMIT_USERNAME"
git config --local user.email "$COMMIT_EMAIL"
cp ../target/formula/restack.rb .
git add restack.rb
git commit -m "restack ${{ env.VERSION }}"
git push
env:
COMMIT_USERNAME: ${{ secrets.AUR_USERNAME }}
COMMIT_EMAIL: ${{ secrets.AUR_EMAIL }}
- name: Publish AUR package (binary)
uses: KSXGitHub/[email protected]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
with:
pkgname: restack-bin
pkgbuild: ./target/aur-bin/PKGBUILD
commit_username: ${{ secrets.AUR_USERNAME }}
commit_email: ${{ secrets.AUR_EMAIL }}
ssh_private_key: ${{ secrets.AUR_KEY }}
commit_message: restack ${{ env.VERSION }}
allow_empty_commits: false
- name: Release Cargo crate
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
run: |
cargo login ${{ secrets.CARGO_TOKEN }}
echo ::group::Publishing files
cargo packge --list
echo ::endgroup::
cargo publish
- name: Publish AUR package (source)
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
uses: KSXGitHub/[email protected]
with:
pkgname: restack
pkgbuild: ./target/aur/PKGBUILD
commit_username: ${{ secrets.AUR_USERNAME }}
commit_email: ${{ secrets.AUR_EMAIL }}
ssh_private_key: ${{ secrets.AUR_KEY }}
commit_message: restack ${{ env.VERSION }}
allow_empty_commits: false
updpkgsums: true