Skip to content

Build typst-package-check #12

Build typst-package-check

Build typst-package-check #12

name: Build typst-package-check
on:
workflow_dispatch:
inputs:
ref:
description: The branch, tag or SHA in https://github.com/typst/package-check.
default: main
type: string
release:
description: Whether to publish artifacts in a new release.
default: false
type: boolean
# The following lines are based on GitHub docs, because typst/package-check uses nix and docker.
# https://docs.github.com/en/actions/tutorials/build-and-test-code/rust
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
matrix:
include:
- target: x86_64-unknown-linux-musl
cargo: cross
- target: x86_64-pc-windows-msvc
cargo: cargo xwin
steps:
- uses: actions/checkout@v4
with:
repository: typst/package-check
ref: ${{ github.event.inputs.ref }}
- uses: actions/checkout@v4
with:
path: dev-builds
- name: Report the revision
shell: bash
id: report
run: |
set -euxo pipefail
revision=$(python dev-builds/scripts/get_revision.py)
echo "Revision: $revision"
echo "revision=$revision" >> "$GITHUB_OUTPUT"
echo "Revision: \`$revision\`." >> "$GITHUB_STEP_SUMMARY"
- run: rustup target add ${{ matrix.target }}
- name: Cache cargo xwin
if: ${{ matrix.cargo == 'cargo xwin' }}
uses: actions/cache@v4
with:
path: |
~/.cache/cargo-xwin
key: |
${{ runner.os }}-cargo-xwin-${{ matrix.target }}
- name: Setup cargo xwin
if: ${{ matrix.cargo == 'cargo xwin' }}
run: |
rustup component add llvm-tools
pip install cargo-xwin
- name: Setup cross
if: ${{ matrix.cargo == 'cross' }}
run: |
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
cargo binstall cross --force # Even if cached, reinstall to set PATH properly.
- name: Vendor openssl for musl
if: ${{ endsWith(matrix.target, '-musl') }}
run: |
cat <<EOF >> Cargo.toml
openssl = { version = "^0.10", features = ["vendored"] }
EOF
- uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ matrix.target }}-typst-package-check-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-${{ matrix.target }}-typst-package-check
${{ runner.os }}-cargo-${{ matrix.target }}
- name: Build
run: |
${{ matrix.cargo }} build --release --target ${{ matrix.target }}
- name: Prepare to upload
shell: bash
run: |
set -euxo pipefail
directory=typst-package-check-${{ matrix.target }}
mkdir $directory
cp README.md LICENSE* $directory
if [ -f target/${{ matrix.target }}/release/typst-package-check.exe ]; then
cp target/${{ matrix.target }}/release/typst-package-check.exe $directory
7z a -r $directory.zip $directory
else
cp target/${{ matrix.target }}/release/typst-package-check $directory
tar cJf $directory.tar.xz $directory
fi
- uses: actions/upload-artifact@v4
with:
name: typst-package-check-${{ matrix.target }}
path: "typst-package-check-${{ matrix.target }}.*"
- uses: softprops/action-gh-release@v2
if: ${{ inputs.release }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.report.outputs.revision }}
name: ${{ steps.report.outputs.revision }}
draft: true
prerelease: false # can be edited in the Web UI
files: |
typst-package-check-${{ matrix.target }}.*
- name: Report the release
if: ${{ inputs.release }}
run: |
echo "Please publish the [draft release](https://github.com/typst-community/dev-builds/releases)." >> "$GITHUB_STEP_SUMMARY"