chore: prepare next release #93
Workflow file for this run
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 | |
on: | |
push: | |
tags: | |
- "v*" | |
jobs: | |
init: | |
runs-on: ubuntu-22.04 | |
outputs: | |
version: ${{steps.version.outputs.version}} | |
prerelease: ${{steps.state.outputs.prerelease}} | |
steps: | |
- name: Evaluate state | |
id: state | |
env: | |
HEAD_REF: ${{github.head_ref}} | |
run: | | |
test -z "${HEAD_REF}" && (echo 'do-publish=true' >> $GITHUB_OUTPUT) | |
if [[ "${{ github.event.ref }}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
echo release=true >> $GITHUB_OUTPUT | |
elif [[ "${{ github.event.ref }}" =~ ^refs/tags/v.*$ ]]; then | |
echo prerelease=true >> $GITHUB_OUTPUT | |
fi | |
- name: Set version | |
id: version | |
run: | | |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | |
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | |
[ "$VERSION" == "main" ] && VERSION=latest | |
echo "Version: $VERSION" | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
target: | |
- x86_64-unknown-linux-gnu | |
- aarch64-unknown-linux-gnu | |
- x86_64-unknown-linux-musl | |
- aarch64-unknown-linux-musl | |
- x86_64-apple-darwin | |
- x86_64-pc-windows-msvc | |
- aarch64-apple-darwin | |
include: | |
- target: x86_64-unknown-linux-gnu | |
os: ubuntu-22.04 | |
name: trunk-x86_64-unknown-linux-gnu.tar.gz | |
- target: aarch64-unknown-linux-gnu | |
os: ubuntu-22.04 | |
name: trunk-aarch64-unknown-linux-gnu.tar.gz | |
cross: "true" | |
# cross's container image is too old for us | |
args: --features vendored | |
- target: x86_64-unknown-linux-musl | |
os: ubuntu-22.04 | |
name: trunk-x86_64-unknown-linux-musl.tar.gz | |
install: | | |
sudo apt install -y musl-tools | |
args: --features vendored | |
- target: aarch64-unknown-linux-musl | |
os: ubuntu-22.04 | |
name: trunk-aarch64-unknown-linux-musl.tar.gz | |
cross: "true" | |
args: --features vendored | |
- target: x86_64-apple-darwin | |
os: macos-12 | |
name: trunk-x86_64-apple-darwin.tar.gz | |
- target: aarch64-apple-darwin | |
os: macos-14 | |
name: trunk-aarch64-apple-darwin.tar.gz | |
- target: x86_64-pc-windows-msvc | |
os: windows-2022 | |
name: trunk-x86_64-pc-windows-msvc.zip | |
ext: ".exe" | |
install: | | |
echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append | |
vcpkg install openssl:x64-windows-static-md | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Setup | Checkout | |
uses: actions/checkout@v4 | |
- name: Setup | Cache Cargo | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Setup | Export GitHub Actions cache environment variables | |
uses: actions/github-script@v7 | |
if: runner.os == 'Windows' | |
with: | |
script: | | |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); | |
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); | |
core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite'); | |
- name: Setup | Install dependencies | |
if: matrix.install != '' | |
run: ${{ matrix.install }} | |
- name: Setup | Disable rustup self-update | |
# workaround for: https://github.com/rust-lang/rustup/issues/3709 | |
run: | | |
rustup set auto-self-update disable | |
- name: Setup | Rust | |
run: | | |
rustup toolchain install stable --target ${{ matrix.target }} --profile minimal | |
rustup default stable | |
- name: Setup | Cross | |
if: matrix.cross == 'true' | |
run: | | |
curl -sSL https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz -o binstall.tar.gz | |
tar xzf binstall.tar.gz | |
mv cargo-binstall $HOME/.cargo/bin/ | |
cargo binstall cross -y | |
- name: Build | Build | |
shell: bash | |
run: | | |
if [[ "${{ matrix.xcode }}" == "true" ]]; then | |
export SDKROOT=$(xcrun -sdk macosx --show-sdk-path) | |
export MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version) | |
fi | |
CMD="cargo" | |
if [[ -n "${{ matrix.cross }}" ]]; then | |
CMD="cross" | |
fi | |
OPTS="--release" | |
OPTS="$OPTS ${{ matrix.args }}" | |
if [[ -n "${{ matrix.target }}" ]]; then | |
OPTS="$OPTS --target=${{ matrix.target }}" | |
fi | |
${CMD} build ${OPTS} | |
- name: Post Build | List output | |
shell: bash | |
run: | | |
ls -l target/ | |
- name: Post Build | Move binary | |
shell: bash | |
run: | | |
mkdir -p upload | |
# if we have an alternate target, there is a sub-directory | |
if [[ -f "target/release/trunk${{ matrix.ext }}" ]]; then | |
SRC="target/release/trunk${{ matrix.ext }}" | |
elif [[ -f "target/${{ matrix.target }}/release/trunk${{ matrix.ext }}" ]]; then | |
SRC="target/${{ matrix.target }}/release/trunk${{ matrix.ext }}" | |
else | |
echo "Unable to find output" | |
find target | |
false # stop build | |
fi | |
# for upload | |
cp -pv "${SRC}" upload/trunk${{ matrix.ext }} | |
- name: Post Build | Strip binary | |
if: matrix.cross != 'true' | |
working-directory: upload | |
run: | | |
ls -l trunk${{matrix.ext}} | |
strip trunk${{matrix.ext}} | |
ls -l trunk${{matrix.ext}} | |
- name: Post Build | Prepare artifacts [zip] | |
if: endsWith(matrix.name, '.zip') | |
working-directory: upload | |
run: | | |
7z a ${{ matrix.name }} trunk${{matrix.ext}} | |
- name: Post Build | Prepare artifacts [tar.gz] | |
if: endsWith(matrix.name, '.tar.gz') | |
working-directory: upload | |
run: | | |
tar czvf ${{ matrix.name }} trunk${{matrix.ext}} | |
- name: Post Build | Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.name }} | |
path: upload/${{ matrix.name }} | |
if-no-files-found: error | |
release: | |
needs: | |
- init | |
- build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup | Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup | Artifacts | |
uses: actions/download-artifact@v4 | |
- name: Setup | Checksums | |
run: for file in trunk-*/trunk-*; do openssl dgst -sha256 -r "$file" | awk '{print $1}' > "${file}.sha256"; done | |
- name: Setup | Install convco | |
run: | | |
curl -sLO https://github.com/convco/convco/releases/download/v0.4.2/convco-ubuntu.zip | |
unzip convco-ubuntu.zip | |
chmod a+x convco | |
sudo mv convco /usr/local/bin | |
- name: Setup | Generate changelog | |
run: | | |
convco changelog -s --max-majors=1 --max-minors=1 --max-patches=1 > RELEASE_LOG.md | |
- name: Build | Publish | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
TAG: v${{ needs.init.outputs.version }} | |
run: | | |
OPTS="" | |
if [[ "${{ needs.init.outputs.prerelease }}" == "true" ]]; then | |
OPTS="${OPTS} -p" | |
fi | |
gh release create ${OPTS} --title "${{ needs.init.outputs.version }}" -F RELEASE_LOG.md ${TAG} \ | |
trunk-*/trunk-* | |
publish: | |
needs: release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup | Checkout | |
uses: actions/checkout@v4 | |
- name: Build | Publish | |
run: cargo publish --token ${{ secrets.CRATES_IO_TOKEN }} | |
pages: | |
needs: | |
- init | |
- publish | |
if: needs.init.outputs.prerelease != 'true' | |
uses: ./.github/workflows/pages.yaml | |
brew: | |
needs: | |
- init | |
- publish | |
if: needs.init.outputs.prerelease != 'true' | |
uses: ./.github/workflows/brew.yaml | |
with: | |
tag-name: v${{ needs.init.outputs.version }} | |
secrets: inherit |