Release #49
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*' | |
workflow_dispatch: | |
inputs: | |
build-binary: | |
description: 'Build Binary' | |
required: false | |
type: boolean | |
default: true | |
draft-release: | |
description: 'Draft Release' | |
required: false | |
type: boolean | |
default: false | |
jobs: | |
extract-version: | |
name: Extract version | |
runs-on: warp-ubuntu-latest-x64-16x | |
outputs: | |
VERSION: ${{ steps.extract_version.outputs.VERSION }} | |
steps: | |
- name: Extract version | |
id: extract_version | |
run: | | |
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then | |
VERSION="${GITHUB_REF#refs/tags/}" | |
else | |
SHA_SHORT="$(echo ${GITHUB_SHA} | cut -c1-7)" | |
BRANCH_NAME_SAFE="${GITHUB_REF_NAME//\//-}" # replaces "/" in branch name with "-" | |
VERSION="${BRANCH_NAME_SAFE}-${SHA_SHORT}" | |
fi | |
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT | |
echo "${VERSION}" | |
echo "### Version: \`${VERSION}\`" >> $GITHUB_STEP_SUMMARY | |
echo "| | |" >> $GITHUB_STEP_SUMMARY | |
echo "| ------------------- | ---------------------- |" >> $GITHUB_STEP_SUMMARY | |
echo "| \`GITHUB_REF_TYPE\` | \`${GITHUB_REF_TYPE}\` |" >> $GITHUB_STEP_SUMMARY | |
echo "| \`GITHUB_REF_NAME\` | \`${GITHUB_REF_NAME}\` |" >> $GITHUB_STEP_SUMMARY | |
echo "| \`GITHUB_REF\` | \`${GITHUB_REF}\` |" >> $GITHUB_STEP_SUMMARY | |
echo "| \`GITHUB_SHA\` | \`${GITHUB_SHA}\` |" >> $GITHUB_STEP_SUMMARY | |
echo "| \`VERSION\` | \`${VERSION}\` |" >> $GITHUB_STEP_SUMMARY | |
build-binary: | |
name: Build binary | |
needs: extract-version | |
if: ${{ github.event.inputs.build-binary == 'true' || github.event_name == 'push'}} # when manually triggered or version tagged | |
runs-on: ${{ matrix.configs.runner }} | |
container: | |
image: ubuntu:22.04 | |
env: | |
VERSION: ${{ needs.extract-version.outputs.VERSION }} | |
permissions: | |
contents: write | |
packages: write | |
strategy: | |
matrix: | |
configs: | |
- target: x86_64-unknown-linux-gnu | |
runner: warp-ubuntu-latest-x64-16x | |
steps: | |
- uses: WarpBuilds/rust-cache@v2 | |
- name: Install dependencies | |
run: | | |
apt-get update | |
apt-get install -y \ | |
build-essential \ | |
curl \ | |
git \ | |
libclang-dev \ | |
libssl-dev \ | |
pkg-config \ | |
protobuf-compiler | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
- uses: actions/checkout@v4 # must install git before checkout and set safe.directory after checkout because of container | |
- name: Prepare filename | |
run: echo "OUTPUT_FILENAME=rbuilder-${VERSION}-${{ matrix.configs.target }}" >> $GITHUB_ENV | |
- name: Build binary | |
run: | | |
git config --global --add safe.directory "$(pwd)" | |
. $HOME/.cargo/env | |
cargo build --release --target ${{ matrix.configs.target }} | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.OUTPUT_FILENAME }} | |
path: target/${{ matrix.configs.target }}/release/rbuilder | |
draft-release: | |
name: Draft release | |
if: ${{ github.event.inputs.draft-release == 'true' || github.event_name == 'push'}} # when manually triggered or version tagged | |
needs: [extract-version, build-binary] | |
runs-on: warp-ubuntu-latest-x64-16x | |
env: | |
VERSION: ${{ needs.extract-version.outputs.VERSION }} | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
merge-multiple: true | |
path: artifacts | |
- name: Record artifacts checksums | |
working-directory: artifacts | |
run: | | |
find ./ || true | |
for file in *; do sha256sum "$file" >> sha256sums.txt; done; | |
cat sha256sums.txt | |
- name: Create release draft | |
uses: softprops/[email protected] | |
id: create-release-draft | |
with: | |
draft: true | |
files: artifacts/* | |
generate_release_notes: true | |
name: ${{ env.VERSION }} | |
tag_name: ${{ env.VERSION }} | |
- name: Write Github Step Summary | |
run: | | |
echo "---" | |
echo "### Release Draft: ${{ env.VERSION }}" >> $GITHUB_STEP_SUMMARY | |
echo "${{ steps.create-release-draft.outputs.url }}" >> $GITHUB_STEP_SUMMARY |