deploy #57
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: deploy | |
on: | |
push: | |
tags: | |
- "v*.*.*" | |
release: | |
types: [published] | |
workflow_dispatch: | |
# Manual trigger. | |
jobs: | |
msvc-windows-binary: | |
runs-on: windows-latest | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install stable | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
target: x86_64-pc-windows-msvc | |
override: true | |
- uses: Swatinem/rust-cache@v2 | |
- name: Build mdbook-katex | |
run: | | |
cargo build --release | |
- name: Get the version | |
shell: bash | |
id: tagName | |
run: | | |
VERSION=$(cargo pkgid | cut -d# -f2 | cut -d: -f2) | |
echo "::set-output name=version::$VERSION" | |
- name: Create zip | |
run: | | |
$ZIP_PREFIX = "mdbook-katex-v${{ steps.tagName.outputs.version }}" | |
7z a "$ZIP_PREFIX-x86_64-pc-windows-msvc.zip" ` | |
"./target/release/mdbook-katex.exe" | |
- name: Upload binary artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
path: mdbook-katex-v${{ steps.tagName.outputs.version }}-x86_64-pc-windows-msvc.zip | |
gnu-windows-binary: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install x86_64-pc-windows-gnu | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
target: x86_64-pc-windows-gnu | |
override: true | |
- uses: Swatinem/rust-cache@v2 | |
- uses: actions-rs/cargo@v1 | |
with: | |
use-cross: true | |
command: build | |
args: | | |
--release | |
--target x86_64-pc-windows-gnu | |
- name: Get the version | |
id: tagName | |
run: | | |
VERSION=$(cargo pkgid | cut -d# -f2 | cut -d: -f2) | |
echo "::set-output name=version::$VERSION" | |
- name: Create tar | |
run: | | |
mv target/x86_64-pc-windows-gnu/release/mdbook-katex.exe mdbook-katex.exe | |
TAR_FILE=mdbook-katex-v${{ steps.tagName.outputs.version }} | |
zip $TAR_FILE-x86_64-pc-windows-gnu.zip \ | |
mdbook-katex.exe | |
- name: Upload binary artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
path: | | |
mdbook-katex-v${{ steps.tagName.outputs.version }}-x86_64-pc-windows-gnu.zip | |
gnu-linux-binary: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install x86_64-unknown-linux-gnu target | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
target: x86_64-unknown-linux-gnu | |
override: true | |
- uses: Swatinem/rust-cache@v2 | |
- name: Build mbdook-katex | |
run: | | |
cargo build --release | |
- name: Get the version | |
id: tagName | |
run: | | |
VERSION=$(cargo pkgid | cut -d# -f2 | cut -d: -f2) | |
echo "::set-output name=version::$VERSION" | |
- name: Create tar | |
run: | | |
mv target/release/mdbook-katex mdbook-katex | |
TAR_FILE=mdbook-katex-v${{ steps.tagName.outputs.version }} | |
tar -czvf $TAR_FILE-x86_64-unknown-linux-gnu.tar.gz \ | |
mdbook-katex | |
- name: Upload binary artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
path: | | |
Cargo.lock | |
mdbook-katex-v${{ steps.tagName.outputs.version }}-x86_64-unknown-linux-gnu.tar.gz | |
musl-linux-binary: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install x86_64-unknown-linux-musl | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
target: x86_64-unknown-linux-musl | |
override: true | |
- uses: Swatinem/rust-cache@v2 | |
- uses: actions-rs/cargo@v1 | |
with: | |
use-cross: true | |
command: build | |
args: | | |
--release | |
--target x86_64-unknown-linux-musl | |
- name: Get the version | |
id: tagName | |
run: | | |
VERSION=$(cargo pkgid | cut -d# -f2 | cut -d: -f2) | |
echo "::set-output name=version::$VERSION" | |
- name: Create tar | |
run: | | |
mv target/x86_64-unknown-linux-musl/release/mdbook-katex mdbook-katex | |
TAR_FILE=mdbook-katex-v${{ steps.tagName.outputs.version }} | |
tar -czvf $TAR_FILE-x86_64-unknown-linux-musl.tar.gz \ | |
mdbook-katex | |
- name: Upload binary artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
path: | | |
mdbook-katex-v${{ steps.tagName.outputs.version }}-x86_64-unknown-linux-musl.tar.gz | |
x86_64-macos-binary: | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install stable-x86_64-apple-darwin | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
target: x86_64-apple-darwin | |
override: true | |
- uses: Swatinem/rust-cache@v2 | |
- name: Build mdbook-katex for x86_64-apple-darwin | |
run: | | |
cargo build --release | |
- name: Get the version | |
id: tagName | |
run: | | |
VERSION=$(cargo pkgid | cut -d# -f2 | cut -d: -f2) | |
echo "::set-output name=version::$VERSION" | |
- name: Create tar for x86_64-apple-darwin | |
run: | | |
mv target/release/mdbook-katex mdbook-katex | |
TAR_PREFIX=mdbook-katex-v${{ steps.tagName.outputs.version }} | |
tar -czvf $TAR_PREFIX-x86_64-apple-darwin.tar.gz \ | |
mdbook-katex | |
- name: Upload binary artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
path: | | |
mdbook-katex-v${{ steps.tagName.outputs.version }}-x86_64-apple-darwin.tar.gz | |
aarch64-macos-binary: | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install stable-aarch64-apple-darwin | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
target: aarch64-apple-darwin | |
override: true | |
- uses: Swatinem/rust-cache@v2 | |
- name: Cross build mdbook-katex for aarch64-apple-darwin | |
run: | | |
cargo build --release --target=aarch64-apple-darwin | |
- name: Get the version | |
id: tagName | |
run: | | |
VERSION=$(cargo pkgid | cut -d# -f2 | cut -d: -f2) | |
echo "::set-output name=version::$VERSION" | |
- name: Create tar for aarch64-apple-darwin | |
run: | | |
mv target/aarch64-apple-darwin/release/mdbook-katex mdbook-katex | |
TAR_PREFIX=mdbook-katex-v${{ steps.tagName.outputs.version }} | |
tar -czvf $TAR_PREFIX-aarch64-apple-darwin.tar.gz \ | |
mdbook-katex | |
- name: Upload binary artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
path: | | |
mdbook-katex-v${{ steps.tagName.outputs.version }}-aarch64-apple-darwin.tar.gz | |
deploy: | |
needs: | |
[ | |
msvc-windows-binary, | |
gnu-windows-binary, | |
gnu-linux-binary, | |
musl-linux-binary, | |
x86_64-macos-binary, | |
aarch64-macos-binary, | |
] | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Download artifacts | |
uses: actions/download-artifact@v2 | |
with: | |
name: artifact | |
- name: Install Rust stable | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
override: true | |
- name: Get the version | |
id: tagName | |
run: | | |
VERSION=$(cargo pkgid | cut -d# -f2 | cut -d: -f2) | |
echo "::set-output name=version::$VERSION" | |
- name: Create a release | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: v${{ steps.tagName.outputs.version }} | |
files: | | |
Cargo.lock | |
mdbook-katex-v${{ steps.tagName.outputs.version }}-aarch64-apple-darwin.tar.gz | |
mdbook-katex-v${{ steps.tagName.outputs.version }}-x86_64-apple-darwin.tar.gz | |
mdbook-katex-v${{ steps.tagName.outputs.version }}-x86_64-pc-windows-msvc.zip | |
mdbook-katex-v${{ steps.tagName.outputs.version }}-x86_64-pc-windows-gnu.zip | |
mdbook-katex-v${{ steps.tagName.outputs.version }}-x86_64-unknown-linux-gnu.tar.gz | |
mdbook-katex-v${{ steps.tagName.outputs.version }}-x86_64-unknown-linux-musl.tar.gz | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
publish: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
- uses: Swatinem/rust-cache@v2 | |
- uses: katyo/publish-crates@v1 | |
with: | |
registry-token: ${{ secrets.CARGO_CREDENTIALS }} |