Skip to content

Release

Release #17

Workflow file for this run

name: Release
on:
release:
types: [published]
workflow_call:
inputs:
tag:
description: 'Tag to release'
required: true
type: string
workflow_dispatch:
inputs:
tag:
description: 'Tag to release (e.g., v0.1.0)'
required: true
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# macOS
- target: x86_64-apple-darwin
os: macos-latest
archive: tar.gz
- target: aarch64-apple-darwin
os: macos-latest
archive: tar.gz
# Linux
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
archive: tar.gz
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
archive: tar.gz
cross: true
# Windows
- target: x86_64-pc-windows-msvc
os: windows-latest
archive: zip
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross-compilation tools
if: matrix.cross
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Package (Unix)
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
tar -czvf ../../../rtk-${{ matrix.target }}.${{ matrix.archive }} rtk
cd ../../..
- name: Package (Windows)
if: matrix.os == 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
7z a ../../../rtk-${{ matrix.target }}.${{ matrix.archive }} rtk.exe
cd ../../..
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: rtk-${{ matrix.target }}
path: rtk-${{ matrix.target }}.${{ matrix.archive }}
build-deb:
name: Build DEB package
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-deb
run: cargo install cargo-deb
- name: Build DEB
run: cargo deb
- name: Upload DEB
uses: actions/upload-artifact@v4
with:
name: rtk-deb
path: target/debian/*.deb
build-rpm:
name: Build RPM package
runs-on: ubuntu-latest
container: fedora:latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
run: |
dnf install -y rust cargo rpm-build
- name: Install cargo-generate-rpm
run: cargo install cargo-generate-rpm
- name: Build release
run: cargo build --release
- name: Generate RPM
run: cargo generate-rpm
- name: Upload RPM
uses: actions/upload-artifact@v4
with:
name: rtk-rpm
path: target/generate-rpm/*.rpm
release:
name: Create Release
needs: [build, build-deb, build-rpm]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Get version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "version=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
elif [ "${{ github.event_name }}" = "workflow_call" ]; then
echo "version=${{ inputs.tag }}" >> $GITHUB_OUTPUT
elif [ "${{ github.event_name }}" = "release" ]; then
echo "version=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
fi
- name: Flatten artifacts
run: |
mkdir -p release
find artifacts -type f \( -name "*.tar.gz" -o -name "*.zip" -o -name "*.deb" -o -name "*.rpm" \) -exec cp {} release/ \;
- name: Create version-agnostic package names
run: |
cd release
for f in *.deb; do
[ -f "$f" ] && cp "$f" "rtk_amd64.deb"
done
for f in *.rpm; do
[ -f "$f" ] && cp "$f" "rtk.x86_64.rpm"
done
- name: Create checksums
run: |
cd release
sha256sum * > checksums.txt
- name: Upload Release Assets
if: github.event_name == 'release' || github.event_name == 'workflow_call'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.version }}
files: release/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
if: github.event_name == 'workflow_dispatch'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.version }}
name: rtk ${{ steps.version.outputs.version }}
draft: false
prerelease: false
generate_release_notes: true
files: release/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# TODO: Enable when HOMEBREW_TAP_TOKEN is configured
# homebrew:
# name: Update Homebrew Tap
# needs: release
# runs-on: ubuntu-latest
# steps:
# - name: Get version
# id: version
# run: |
# if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
# echo "version=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
# else
# echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
# fi
#
# - name: Update Homebrew formula
# uses: mislav/bump-homebrew-formula-action@v3
# with:
# formula-name: rtk
# homebrew-tap: pszymkowiak/homebrew-tap
# tag-name: ${{ steps.version.outputs.version }}
# download-url: https://github.com/pszymkowiak/rtk/releases/download/${{ steps.version.outputs.version }}/rtk-x86_64-apple-darwin.tar.gz
# env:
# COMMITTER_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}