1
Fork 0
mdbook-toc/.github/workflows/deploy.yml

119 lines
3.6 KiB
YAML
Raw Normal View History

2021-01-05 19:41:11 +00:00
# Based on https://github.com/starship/starship/blob/master/.github/workflows/deploy.yml
name: Deploy
on:
push:
tags:
- "*"
env:
CRATE_NAME: mdbook-toc
jobs:
# Build sources for every OS
github_build:
name: Build release binaries
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- x86_64-apple-darwin
2022-11-01 19:05:38 +00:00
- aarch64-apple-darwin
2021-01-05 19:41:11 +00:00
- x86_64-pc-windows-msvc
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
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
2022-11-01 19:05:38 +00:00
- target: aarch64-apple-darwin
os: macOS-latest
name: aarch64-apple-darwin.tar.gz
2021-01-05 19:41:11 +00:00
- target: x86_64-pc-windows-msvc
os: windows-latest
name: x86_64-pc-windows-msvc.zip
runs-on: ${{ matrix.os }}
steps:
- name: Setup | Checkout
2022-11-01 19:05:26 +00:00
uses: actions/checkout@v3
2021-01-05 19:41:11 +00:00
- name: Setup | Rust
2023-05-15 19:37:00 +00:00
uses: dtolnay/rust-toolchain@stable
2021-01-05 19:41:11 +00:00
with:
target: ${{ matrix.target }}
2023-05-15 19:37:00 +00:00
- uses: Swatinem/rust-cache@v2
2022-11-01 19:05:26 +00:00
2021-01-05 19:41:11 +00:00
- name: Setup | musl tools
if: matrix.target == 'x86_64-unknown-linux-musl'
run: sudo apt install -y musl-tools
- name: Build | Build
if: matrix.target != 'x86_64-unknown-linux-musl'
run: cargo build --release --target ${{ matrix.target }}
- name: Build | Build (musl)
if: matrix.target == 'x86_64-unknown-linux-musl'
run: cargo build --release --target ${{ matrix.target }}
- name: Post Setup | Extract tag name
shell: bash
run: echo "##[set-output name=tag;]$(echo ${GITHUB_REF#refs/tags/})"
id: extract_tag
- name: Post Setup | Prepare artifacts [Windows]
if: matrix.os == 'windows-latest'
run: |
mkdir target/stage
cd target/${{ matrix.target }}/release
strip ${{ env.CRATE_NAME }}.exe
7z a ../../stage/${{ env.CRATE_NAME }}-${{ steps.extract_tag.outputs.tag }}-${{ matrix.name }} ${{ env.CRATE_NAME }}.exe
2021-01-05 19:41:11 +00:00
cd -
- name: Post Setup | Prepare artifacts [-nix]
if: matrix.os != 'windows-latest'
run: |
mkdir target/stage
cd target/${{ matrix.target }}/release
strip ${{ env.CRATE_NAME }}
tar czvf ../../stage/${{ env.CRATE_NAME }}-${{ steps.extract_tag.outputs.tag }}-${{ matrix.name }} ${{ env.CRATE_NAME }}
cd -
- name: Post Setup | Upload artifacts
2022-11-01 19:05:26 +00:00
uses: actions/upload-artifact@v3
2021-01-05 19:41:11 +00:00
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
2022-11-01 19:05:26 +00:00
uses: actions/checkout@v3
2021-01-05 19:41:11 +00:00
with:
fetch-depth: 0
- name: Setup | Artifacts
2022-11-01 19:05:26 +00:00
uses: actions/download-artifact@v3
2021-01-05 19:41:11 +00:00
- name: Setup | Release notes
run: |
git log -1 --pretty='%s' > 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 }}