Skip to content

Create Release

Create Release #24

Workflow file for this run

name: Create Release
on:
workflow_dispatch:
inputs:
draft:
required: false
default: true
description: Produce a draft release
type: boolean
jobs:
get-tags:
name: Create tagged release
runs-on: ubuntu-latest
outputs:
crate-version: ${{ steps.crate-version.outputs.CRATE_VERSION }}
old-version: ${{ steps.old-version.outputs.OLD_VERSION }}
steps:
- uses: actions/checkout@v4
- name: Get old tag
id: old-version
shell: bash
run: |
echo OLD_VERSION="$(curl "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/tags" | jq -r '.[0].name')" >> $GITHUB_OUTPUT
- name: Get tag
id: crate-version
shell: bash
run: |
echo CRATE_VERSION=$(awk -F ' = ' '$1 ~ /version/ { gsub(/["]/, "", $2); printf("%s",$2) }' Cargo.toml) >> $GITHUB_OUTPUT
- run: "echo '::notice:: Tag = v${{ steps.crate-version.outputs.CRATE_VERSION }}'"
- name: Create draft release
if: ${{ github.event.inputs.draft }}
run: >
envsubst '$CRATE_VERSION $OLD_VERSION' < .github/release-notes.md |
gh release create "v$CRATE_VERSION" --title "v$CRATE_VERSION" --notes-file - --draft
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
CRATE_VERSION: ${{ steps.crate-version.outputs.CRATE_VERSION }}
OLD_VERSION: ${{ steps.old-version.outputs.OLD_VERSION }}
- name: Create release
if: ${{ !github.event.inputs.draft }}
run: >
envsubst '$CRATE_VERSION $OLD_VERSION' < .github/release-notes.md |
gh release create "v$CRATE_VERSION" --notes-file -
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
CRATE_VERSION: ${{ steps.crate-version.outputs.CRATE_VERSION }}
OLD_VERSION: ${{ steps.old-version.outputs.OLD_VERSION }}
build:
name: Build & Upload
runs-on: ${{ matrix.os }}
needs:
- get-tags
strategy:
fail-fast: false
matrix:
build:
- x86_64-linux
- x86_64-linux-musl
- x86_64-windows
feature:
- data-center
- cloud
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
build: x86_64-linux
ext: ""
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
build: x86_64-linux-musl
ext: ""
- target: x86_64-pc-windows-msvc
os: windows-latest
build: x86_64-windows
ext: .exe
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: cargo-release-${{ matrix.build }}-${{ matrix.feature }}-${{ hashFiles('**/Cargo.toml') }}
restore-keys: cargo-release-${{ matrix.build }}-${{ matrix.feature }}-
- if: ${{ contains(matrix.target, '-musl')}}
run: sudo apt install musl-tools
- uses: dtolnay/rust-toolchain@nightly
with:
targets: ${{ matrix.target }}
- name: "Build ${{ matrix.build }} features: ${{ matrix.feature }}"
run: cargo +nightly build --release --features ${{ matrix.feature }} --target ${{ matrix.target }}
env:
RUSTFLAGS: -Zlocation-detail=none
- run: mkdir dist
- run: mv target/${{ matrix.target }}/release/jig${{ matrix.ext }} dist/jig-${{ matrix.feature }}-${{ matrix.target }}${{ matrix.ext }}
- run: gh release upload 'v${{ needs.get-tags.outputs.crate-version }}' dist/jig-${{ matrix.feature }}-${{ matrix.target }}${{ matrix.ext }}
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- run: "echo '::notice:: Upload finished: jig-${{ matrix.feature }}-${{ matrix.target }}${{ matrix.ext }}'"