name: GitHub release
on:
workflow_dispatch:
inputs:
ezno-version:
description: "Semver for Ezno (CLI) to release on"
required: false
default: "latest"
env:
CACHE_PATHS: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
jobs:
get-build-info:
runs-on: ubuntu-latest
outputs:
LATEST_EZNO_VERSION: ${{ steps.get-version.outputs.LATEST_EZNO_VERSION }}
LATEST_EZNO_VERSION_DASH: ${{ steps.get-version.outputs.LATEST_EZNO_VERSION_DASH }}
SPONSORS: ${{ steps.get-sponsors-and-contributors.outputs.SPONSORS }}
CONTRIBUTORS: ${{ steps.get-sponsors-and-contributors.outputs.CONTRIBUTORS }}
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true
- name: Get version
id: get-version
run: |
if [ ${{ inputs.ezno-version }} = 'latest' ]; then
echo "::group::Ezno tags"
git for-each-ref --sort=creatordate --format '%(refname:short)' 'refs/tags/release/ezno-[0-9]*'
echo "::endgroup::"
TAG=$(git for-each-ref --sort=creatordate --format '%(refname:short)' 'refs/tags/release/ezno-[0-9]*' | tail -n 1 | cut -c 14-)
echo "::notice::Releasing with found version $TAG"
echo "LATEST_EZNO_VERSION=${TAG}" >> "$GITHUB_OUTPUT"
echo "LATEST_EZNO_VERSION_DASH=${TAG//./-}" >> "$GITHUB_OUTPUT"
else
TAG="${{ inputs.ezno-version }}"
echo "::notice::Releasing with specific version $TAG"
echo "LATEST_EZNO_VERSION=${TAG}" >> "$GITHUB_OUTPUT"
echo "LATEST_EZNO_VERSION_DASH=${TAG//./-}" >> "$GITHUB_OUTPUT"
fi
- name: Get sponsors and contributors
id: get-sponsors-and-contributors
run: |
SQP='.data.user.sponsorshipsAsMaintainer.edges | map(.node.sponsor.name // .node.sponsor.login) | join(",")'
GQL_SQ='{ user(login: "kaleidawave") { sponsorshipsAsMaintainer(first: 100, activeOnly: false) { edges { node { sponsor { name, login } } } } } }'
SPONSORS=$(gh api graphql -f query="$GQL_SQ" -q "$SQP")
CQP='map(.author.name // .author.login) | unique | join(",")'
CONTRIBUTORS=$(gh pr list --state merged --json author | jq "$CQP" --raw-output)
echo "SPONSORS=$SPONSORS" >> "$GITHUB_OUTPUT"
echo "CONTRIBUTORS=$CONTRIBUTORS" >> "$GITHUB_OUTPUT"
echo "::notice::CONTRIBUTORS=$CONTRIBUTORS and SPONSORS=$SPONSORS"
shell: bash
env:
GH_TOKEN: ${{ github.token }}
build:
needs: [get-build-info]
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
include:
- os: windows-latest
platform-name: x86_64-pc-windows
executable-extension: ".exe"
- os: ubuntu-latest
platform-name: x86_64-unknown-linux
runs-on: ${{ matrix.os }}
env:
LEVEL: release
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v4
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build binary
run: cargo build --release
env:
SPONSORS: ${{ needs.get-build-info.outputs.SPONSORS }}
CONTRIBUTORS: ${{ needs.get-build-info.outputs.CONTRIBUTORS }}
- name: Rename and move ${{ env.LEVEL }} assets
run: |
mkdir artifacts
mv "target/${{ env.LEVEL }}/ezno${{ matrix.executable-extension }}" "artifacts/ezno-${{ needs.get-build-info.outputs.LATEST_EZNO_VERSION_DASH }}-${{ matrix.platform-name }}${{ matrix.executable-extension }}"
- uses: actions/upload-artifact@v4
with:
name: build-artifacts-${{ matrix.os }}
path: artifacts/*
if-no-files-found: error
retention-days: 1
github-release:
needs: [build, get-build-info]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: build-artifacts
pattern: build-artifacts-*
merge-multiple: true
- name: Print artifacts
run: |
echo "::group::Build artifacts"
ls -R build-artifacts
echo "::endgroup::"
- name: GitHub release
uses: softprops/action-gh-release@v1
with:
name: "Ezno ${{ needs.get-build-info.outputs.LATEST_EZNO_VERSION }}"
tag_name: "release/ezno-${{ needs.get-build-info.outputs.LATEST_EZNO_VERSION }}"
body: "For @kaleidawave to update"
files: |
README.md
build-artifacts/*