shiroa::release #22
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: shiroa::release | |
on: | |
release: | |
types: [created] | |
workflow_dispatch: | |
env: | |
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc | |
CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc | |
SCCACHE_GHA_ENABLED: 'true' | |
RUSTC_WRAPPER: 'sccache' | |
jobs: | |
build-frontend-packages: | |
name: build (Frontend packages) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Install Yarn | |
uses: borales/actions-yarn@v4 | |
with: | |
cmd: install # will run `yarn install` command | |
dir: 'frontend' | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # if needed | |
- name: Build JavaScript packages | |
uses: borales/actions-yarn@v4 | |
with: | |
cmd: build | |
dir: 'frontend' | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: typst-ts-dist | |
path: frontend/node_modules/@myriaddreamin | |
if-no-files-found: error | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: shiroa-dist | |
path: frontend/dist | |
if-no-files-found: error | |
build: | |
strategy: | |
matrix: | |
include: | |
- os: windows-latest | |
rust-target: x86_64-pc-windows-msvc | |
platform: win32 | |
arch: x64 | |
- os: windows-latest | |
rust-target: i686-pc-windows-msvc | |
platform: win32 | |
arch: ia32 | |
- os: windows-latest | |
rust-target: aarch64-pc-windows-msvc | |
platform: win32 | |
arch: arm64 | |
- os: ubuntu-latest | |
rust-target: x86_64-unknown-linux-gnu | |
platform: linux | |
arch: x64 | |
- os: ubuntu-latest | |
rust-target: aarch64-unknown-linux-gnu | |
platform: linux | |
arch: arm64 | |
- os: ubuntu-latest | |
rust-target: arm-unknown-linux-gnueabihf | |
platform: linux | |
arch: armhf | |
- os: macos-13 | |
rust-target: x86_64-apple-darwin | |
platform: darwin | |
arch: x64 | |
- os: macos-13 | |
rust-target: aarch64-apple-darwin | |
platform: darwin | |
arch: arm64 | |
name: build (${{ matrix.rust-target }}) | |
runs-on: ${{ matrix.os }} | |
env: | |
target: ${{ matrix.platform }}-${{ matrix.arch }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Run sccache-cache | |
uses: mozilla-actions/[email protected] | |
- name: rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.rust-target }} | |
- name: Install AArch64 target toolchain | |
if: matrix.rust-target == 'aarch64-unknown-linux-gnu' | |
run: | | |
sudo apt-get update -y | |
sudo apt-get install gcc-aarch64-linux-gnu | |
- name: Install ARM target toolchain | |
if: matrix.rust-target == 'arm-unknown-linux-gnueabihf' | |
run: | | |
sudo apt-get update -y | |
sudo apt-get install gcc-arm-linux-gnueabihf | |
- name: Install Yarn | |
uses: borales/actions-yarn@v4 | |
with: | |
cmd: install # will run `yarn install` command | |
dir: 'frontend' | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # if needed | |
- name: Build JavaScript packages | |
uses: borales/actions-yarn@v4 | |
with: | |
cmd: build | |
dir: 'frontend' | |
- name: Run Native Build | |
shell: pwsh | |
run: | | |
cargo build --release --manifest-path cli/Cargo.toml --target ${{ matrix.rust-target }} --bin shiroa | |
cargo build --profile relwithdebinfo --manifest-path cli/Cargo.toml --target ${{ matrix.rust-target }} --bin shiroa | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: shiroa-${{ env.target }} | |
path: target/${{ matrix.rust-target }}/release/shiroa* | |
if-no-files-found: error | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: shiroa-${{ env.target }}-relwithdebuginfo | |
path: target/${{ matrix.rust-target }}/relwithdebinfo/shiroa* | |
if-no-files-found: error | |
build_linux_riscv64: | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
rust-target: riscv64gc-unknown-linux-gnu | |
platform: linux | |
arch: riscv64 | |
name: build (${{ matrix.rust-target }}) | |
needs: [build-frontend-packages] | |
runs-on: ${{ matrix.os }} | |
env: | |
target: ${{ matrix.platform }}-${{ matrix.arch }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- uses: actions/download-artifact@v2 | |
with: | |
path: artifacts | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
target: ${{ matrix.rust-target }} | |
- name: Build cross image | |
run: | | |
docker build -t shiroa/riscv64 ${GITHUB_WORKSPACE}/.github/cross-linux-riscv64/ | |
env: | |
CROSS_DOCKER_IN_DOCKER: true | |
- name: Run Cross Build | |
run: | | |
mkdir -p frontend/node_modules | |
cp -r artifacts/typst-ts-dist frontend/node_modules/@myriaddreamin | |
cp -r artifacts/shiroa-dist frontend/dist | |
docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${GITHUB_WORKSPACE}:/project -w /project shiroa/riscv64:latest cargo build --manifest-path cli/Cargo.toml --release --target ${CARGO_TARGET} --bin shiroa | |
docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${GITHUB_WORKSPACE}:/project -w /project shiroa/riscv64:latest cargo build --manifest-path cli/Cargo.toml --profile relwithdebinfo --target ${CARGO_TARGET} --bin shiroa | |
env: | |
CROSS_DOCKER_IN_DOCKER: true | |
CARGO_TARGET: ${{ matrix.rust-target }} | |
PKG_CONFIG_PATH: /usr/lib/riscv64-linux-gnu/pkgconfig | |
PKG_CONFIG_ALLOW_CROSS: true | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: shiroa-${{ env.target }} | |
path: target/${{ matrix.rust-target }}/release/shiroa* | |
if-no-files-found: error | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: shiroa-${{ env.target }}-relwithdebuginfo | |
path: target/${{ matrix.rust-target }}/relwithdebinfo/shiroa* | |
if-no-files-found: error | |
build_alpine: | |
name: build (x86_64-unknown-linux-musl) | |
runs-on: ubuntu-latest | |
container: | |
image: rust:alpine | |
volumes: | |
- /usr/local/cargo/registry:/usr/local/cargo/registry | |
env: | |
target: alpine-x64 | |
RUST_TARGET: x86_64-unknown-linux-musl | |
RUSTFLAGS: '-C link-arg=-fuse-ld=lld -C target-feature=-crt-static' | |
steps: | |
- name: Install dependencies | |
run: apk add --no-cache git clang lld musl-dev npm | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Run sccache-cache | |
uses: mozilla-actions/[email protected] | |
- name: Configure git | |
run: | | |
git config --global --add safe.directory $PWD | |
- name: Install Yarn | |
uses: borales/actions-yarn@v4 | |
with: | |
cmd: install # will run `yarn install` command | |
dir: 'frontend' | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # if needed | |
- name: Build JavaScript packages | |
uses: borales/actions-yarn@v4 | |
with: | |
cmd: build | |
dir: 'frontend' | |
- name: build binaries | |
run: | | |
cargo build --release --manifest-path cli/Cargo.toml --target $RUST_TARGET --bin shiroa | |
cargo build --profile relwithdebuginfo --manifest-path cli/Cargo.toml --target $RUST_TARGET --bin shiroa | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: shiroa-${{ env.target }}-relwithdebuginfo | |
path: target/${{ env.RUST_TARGET }}/relwithdebuginfo/shiroa* | |
if-no-files-found: error | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: shiroa-${{ env.target }} | |
path: target/${{ env.RUST_TARGET }}/release/shiroa* | |
if-no-files-found: error | |
release: | |
runs-on: ubuntu-latest | |
needs: [build, build_linux_riscv64, build_alpine] | |
if: success() && startsWith(github.ref, 'refs/tags/') | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/download-artifact@v2 | |
with: | |
path: artifacts | |
- name: Display structure of downloaded files | |
run: find artifacts | |
- run: | | |
set -ex | |
mkdir -p gh-release/ | |
pack_release() { | |
target=$2 | |
src=shiroa-$1 | |
name=shiroa-$target | |
mkdir -p tmp/$name | |
rm -f artifacts/$src/*.d | |
rm -f artifacts/$src/*.pdb | |
mkdir -p release/$name/bin | |
cp artifacts/$src/shiroa* "release/$name/bin/" | |
cp -r CHANGELOG release/$name/ | |
cp -r github-pages/docs release/$name/ | |
cp README.md \ | |
LICENSE \ | |
CHANGELOG.md \ | |
release/$name/ | |
chmod +x release/$name/bin/shiroa* | |
tar czvf gh-release/$name.tar.gz -C release $name | |
mkdir -p relwithdebinfo/$name/bin | |
cp artifacts/$src-relwithdebuginfo/shiroa* "relwithdebinfo/$name/bin/" | |
cp -r CHANGELOG relwithdebinfo/$name/ | |
cp -r github-pages/docs relwithdebinfo/$name/ | |
cp README.md \ | |
LICENSE \ | |
CHANGELOG.md \ | |
relwithdebinfo/$name/ | |
chmod +x relwithdebinfo/$name/bin/shiroa* | |
tar czvf gh-release/$name-relwithdebuginfo.tar.gz -C relwithdebinfo $name | |
} | |
pack_release win32-x64 x86_64-pc-windows-msvc | |
pack_release win32-ia32 i686-pc-windows-msvc | |
pack_release win32-arm64 aarch64-pc-windows-msvc | |
pack_release linux-x64 x86_64-unknown-linux-gnu | |
pack_release linux-arm64 aarch64-unknown-linux-gnu | |
pack_release linux-armhf arm-unknown-linux-gnueabihf | |
pack_release linux-riscv64 riscv64gc-unknown-linux-gnu | |
pack_release darwin-x64 x86_64-apple-darwin | |
pack_release darwin-arm64 aarch64-apple-darwin | |
pack_release alpine-x64 alpine-x64 | |
pack_release alpine-x64 x86_64-unknown-linux-musl | |
- name: Display structure of releasing files | |
run: find gh-release | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: gh-release | |
path: gh-release | |
- uses: ncipollo/release-action@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
artifacts: 'gh-release/*' | |
allowUpdates: true | |
omitBodyDuringUpdate: true | |
omitDraftDuringUpdate: true | |
omitNameDuringUpdate: true | |
omitPrereleaseDuringUpdate: true |