Merge pull request #199 from tommilligan/prep-1.18.0 #24
Workflow file for this run
This file contains hidden or 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
# Based on https://github.com/starship/starship/blob/master/.github/workflows/deploy.yml | |
name: Deploy | |
on: | |
push: | |
tags: | |
- "*" | |
env: | |
CRATE_NAME: mdbook-admonish | |
jobs: | |
# Build sources for every OS | |
github_build: | |
name: Build release binaries | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- target: aarch64-unknown-linux-musl | |
os: ubuntu-latest | |
name: aarch64-unknown-linux-musl.tar.gz | |
- target: x86_64-unknown-linux-gnu | |
# Deliberately pinned to the same version `mdbook` uses to build | |
# binaries, so we use the same glibc version | |
# | |
# ref: https://github.com/rust-lang/mdBook/pull/1955 | |
os: ubuntu-20.04 | |
name: x86_64-unknown-linux-gnu.tar.gz | |
- target: x86_64-unknown-linux-musl | |
os: ubuntu-latest | |
name: x86_64-unknown-linux-musl.tar.gz | |
- target: x86_64-apple-darwin | |
os: macOS-latest | |
name: x86_64-apple-darwin.tar.gz | |
- target: x86_64-pc-windows-msvc | |
os: windows-latest | |
name: x86_64-pc-windows-msvc.zip | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Setup | Checkout | |
uses: actions/checkout@v4 | |
# Cache files between builds | |
- name: Setup | Cache Cargo | |
uses: actions/cache@v4 | |
with: | |
# Note that we don't cache the `target` directory here | |
# so we do a completely clean rebuild for artefacts | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Setup | Rust | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
target: ${{ matrix.target }} | |
- name: Setup | cross | |
if: endsWith(matrix.target, '-unknown-linux-musl') | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: cross | |
- name: Build | Build | |
if: ${{ !endsWith(matrix.target, '-unknown-linux-musl') }} | |
run: cargo build --release --target ${{ matrix.target }} | |
- name: Build | Build (musl) | |
if: endsWith(matrix.target, '-unknown-linux-musl') | |
run: cross build --release --target ${{ matrix.target }} | |
- name: Post Setup | Extract tag name | |
shell: bash | |
run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
id: extract_tag | |
- name: Post Setup | Prepare artifacts [Windows] | |
if: matrix.os == 'windows-latest' | |
run: | | |
mkdir target/stage | |
cd target/${{ matrix.target }}/release | |
7z a ../../stage/${{ env.CRATE_NAME }}-${{ steps.extract_tag.outputs.tag }}-${{ matrix.name }} ${{ env.CRATE_NAME }}.exe | |
cd - | |
- name: Post Setup | Prepare artifacts [-nix] | |
if: matrix.os != 'windows-latest' | |
run: | | |
mkdir target/stage | |
cd target/${{ matrix.target }}/release | |
tar czvf ../../stage/${{ env.CRATE_NAME }}-${{ steps.extract_tag.outputs.tag }}-${{ matrix.name }} ${{ env.CRATE_NAME }} | |
cd - | |
- name: Post Setup | Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.CRATE_NAME }}-${{ steps.extract_tag.outputs.tag }}-${{ matrix.name }} | |
path: target/stage/* | |
# Create GitHub release with Rust build targets and release notes | |
github_release: | |
name: Create GitHub Release | |
needs: github_build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup | Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup | Artifacts | |
uses: actions/download-artifact@v3 | |
- name: Setup | Extract version | |
shell: bash | |
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
id: extract_version | |
- name: Setup | Release notes | |
run: | | |
cat CHANGELOG.md | sed -n '/^## ${{ steps.extract_version.outputs.version }}$/,/^## /p' | sed '$d' > RELEASE.md | |
- name: Build | Publish | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: ${{ env.CRATE_NAME }}-*/${{ env.CRATE_NAME }}-* | |
body_path: RELEASE.md | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Upload to crates.io | |
publish: | |
name: Publish to crates.io | |
needs: github_release | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
~/.cargo/bin | |
# We reuse the cache from our detailed test environment, if available | |
key: detailed-test-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }} | |
- name: Install toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
- name: Publish crate | |
env: | |
CARGO_LOGIN_TOKEN: ${{ secrets.CARGO_LOGIN_TOKEN }} | |
run: ./scripts/publish |