Skip to content

Bump actions/checkout from 2 to 4 (#40) #163

Bump actions/checkout from 2 to 4 (#40)

Bump actions/checkout from 2 to 4 (#40) #163

Workflow file for this run

name: mdbook-pdf build
on:
workflow_dispatch: # Allow manual triggers
push:
branches: [ main ]
# Publish `v1.2.3` tags as releases.
tags:
- v*
pull_request:
branches: [ main ]
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- target: "x86_64-apple-darwin"
os: "macos-latest"
- target: "aarch64-apple-darwin"
os: "macos-latest"
- target: "x86_64-unknown-linux-gnu"
os: "ubuntu-latest"
- target: "x86_64-unknown-linux-musl"
os: "ubuntu-latest"
# - target: "i686-unknown-linux-gnu"
# os: "ubuntu-latest"
- target: "i686-unknown-linux-musl"
os: "ubuntu-latest"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- uses: Swatinem/rust-cache@v2
- name: Get latest tag
run: |
echo "VERSION=$(git -c 'versionsort.suffix=-' ls-remote \
--tags --sort='-v:refname' https://github.com/HollowMan6/mdbook-pdf \
| cut -d '/' -f3 | head -1)" >> $GITHUB_ENV
- name: Add target
run: |
rustup target add ${{ matrix.target }}
- name: Clippy check
run: |
cargo clippy
- name: Build mdbook-pdf Release
run: |
cargo build --release --target ${{ matrix.target }}
- name: Upload Binary File to release
if: startsWith(github.ref, 'refs/tags/v')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
asset_name: mdbook-pdf-${{ env.VERSION }}-${{ matrix.target }}
file: target/${{ matrix.target }}/release/mdbook-pdf
tag: ${{ env.VERSION }}
overwrite: true
- name: Upload Binary File to Artifact
uses: actions/upload-artifact@v4
with:
name: mdbook-pdf-${{ env.VERSION }}-${{ matrix.target }}
path: target/${{ matrix.target }}/release/mdbook-pdf
build-windows:
runs-on: "windows-latest"
strategy:
fail-fast: false
matrix:
target: ["x86_64-pc-windows-msvc", "x86_64-pc-windows-gnu", "aarch64-pc-windows-msvc", "i686-pc-windows-msvc"]
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- uses: Swatinem/rust-cache@v2
- name: Get latest tag
run: |
$c = git -c 'versionsort.suffix=-' ls-remote `
--tags --sort='-v:refname' https://github.com/HollowMan6/mdbook-pdf `
| select -first 1
$tag = $c -split "/" | select -last 1
echo "VERSION=$tag" >> $env:GITHUB_ENV
- name: Add target
run: |
rustup target add ${{ matrix.target }}
- name: Build mdbook-pdf Release
run: |
cargo build --release --target ${{ matrix.target }}
- name: Upload Binary File to release
if: startsWith(github.ref, 'refs/tags/v')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
asset_name: mdbook-pdf-${{ env.VERSION }}-${{ matrix.target }}.exe
file: target/${{ matrix.target }}/release/mdbook-pdf.exe
tag: ${{ env.VERSION }}
overwrite: true
- name: Upload Binary File to Artifact
uses: actions/upload-artifact@v4
with:
name: mdbook-pdf-${{ env.VERSION }}-${{ matrix.target }}
path: target/${{ matrix.target }}/release/mdbook-pdf.exe
build-linux-aarch64:
strategy:
fail-fast: false
matrix:
target: ["aarch64-unknown-linux-musl", "aarch64-unknown-linux-gnu"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Get latest tag
run: |
echo "VERSION=$(git -c 'versionsort.suffix=-' ls-remote \
--tags --sort='-v:refname' https://github.com/HollowMan6/mdbook-pdf \
| cut --delimiter='/' --fields=3 | head --lines=1)" >> $GITHUB_ENV
- name: Build mdbook-pdf Release
run: |
mkdir .cargo
echo "[net]" >> .cargo/config.toml
echo "git-fetch-with-cli = true" >> .cargo/config.toml
docker run -i -v /usr/bin/qemu-aarch64-static:/usr/bin/qemu-aarch64-static \
-v `pwd`:/build \
-w /build --platform arm64 rust bash -c \
"rustup target add ${{ matrix.target }} && cargo build --release --target ${{ matrix.target }}"
- name: Upload Binary File to release
if: startsWith(github.ref, 'refs/tags/v')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
asset_name: mdbook-pdf-${{ env.VERSION }}-${{ matrix.target }}
file: target/${{ matrix.target }}/release/mdbook-pdf
tag: ${{ env.VERSION }}
overwrite: true
- name: Upload Binary File to Artifact
uses: actions/upload-artifact@v4
with:
name: mdbook-pdf-${{ env.VERSION }}-${{ matrix.target }}
path: target/${{ matrix.target }}/release/mdbook-pdf