cargo zigbuild #2
Workflow file for this run
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: Release | ||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
- 'commit-*' | ||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
env: | ||
RUSTC_WRAPPER: sccache | ||
SCCACHE_CACHE_SIZE: 1G | ||
SCCACHE_DIR: /home/runner/.cache/sccache | ||
# SCCACHE_RECACHE: 1 # Uncomment this to clear cache, then comment | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
lfs: true | ||
submodules: 'recursive' | ||
path: zig-release | ||
- name: Setup variables | ||
id: variables | ||
run: | | ||
VER=${GITHUB_REF##*/} | ||
VER=${VER#commit-} | ||
VER=${VER%-release} | ||
echo "version=${VER}" >> $GITHUB_OUTPUT | ||
- uses: actions/checkout@v4 | ||
with: | ||
lfs: true | ||
submodules: 'recursive' | ||
path: pulldown-cmark | ||
- name: checkout tag | ||
run: | | ||
cd pulldown-cmark | ||
git fetch --tags | ||
git checkout --detach ${{ steps.variables.outputs.version }} | ||
git describe --tags --always HEAD| sed -e 's/^v//g' -e 's/-g.*$//g' -e 's/-/+/g' > version.txt | ||
cat version.txt | ||
- name: Generate release tag | ||
id: release_tag | ||
run: | | ||
echo "release_tag=$(cat pulldown-cmark/version.txt)" >> $GITHUB_OUTPUT | ||
- name: Generate release note | ||
id: release_note | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
cd pulldown-cmark | ||
const name = 'release_note' | ||
const value = "$(git log -1 ${{ steps.variables.outputs.version }}" | ||
core.setOutput(name, value) | ||
- name: test | ||
run: | | ||
echo "1: ${{ steps.release_tag.outputs.release_tag }}" | ||
echo "2: ${{ steps.release_note.outputs.release_note }}" | ||
- name: copy Makefile for zig-release | ||
run: | | ||
mkdir -p source | ||
cd pulldown-cmark | ||
cd ../zig-release | ||
cp Makefile archive.sh target.txt ../pulldown-cmark/ | ||
cp config.toml target.txt ../ | ||
- name: install zig and tools (Linux) | ||
run: | | ||
#pacman -Sy sudo rustup clang llvm lld make git --noconfirm | ||
sudo apt-get install build-essential make git clang binutils-mingw-w64 | ||
rm -f ~/.cargo/config* | ||
mkdir -p zig | ||
curl -LZ https://ziglang.org/download/0.11.0/zig-linux-x86_64-0.11.0.tar.xz|tar xJ --strip-component=1 -C zig | ||
sudo mv zig /usr/local/ | ||
echo "/usr/local/zig" >> $GITHUB_PATH | ||
- name: Install sccache | ||
env: | ||
LINK: https://github.com/mozilla/sccache/releases/download | ||
SCCACHE_VERSION: 0.7.6 | ||
run: | | ||
SCCACHE_FILE=sccache-v$SCCACHE_VERSION-x86_64-unknown-linux-musl | ||
mkdir -p $HOME/.local/bin | ||
curl -L "$LINK/v$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz | ||
mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache | ||
chmod +x $HOME/.local/bin/sccache | ||
echo "$HOME/.local/bin" >> $GITHUB_PATH | ||
- name: Install mold linker | ||
uses: rui314/setup-mold@staging | ||
with: | ||
mold-version: 2.4.0 | ||
make-default: true | ||
- name: Cache toolchain | ||
uses: Swatinem/rust-cache@v2 | ||
- name: Update toolchain | ||
run: | | ||
rustup update nightly | ||
rustup default nightly | ||
rustup component add rust-src | ||
rustup target add $(cat target.txt) | ||
rustup +stable target add $(cat target.txt) | ||
- name: Install cargo-zigbuild | ||
run: | | ||
cargo install cargo-zigbuild --target x86_64-unknown-linux-gnu | ||
- name: config.toml | ||
run: | | ||
mkdir -p ~/.cargo/ | ||
rm -f ~/.cargo/config* | ||
cp config.toml ~/.cargo/config.toml | ||
- name: Build and archive | ||
shell: bash | ||
run: | | ||
cd pulldown-cmark | ||
make target-archive | ||
- name: Create release | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
tag: "${{ steps.release_tag.outputs.release_tag }}" | ||
name: "${{ steps.release_tag.outputs.release_tag }}" | ||
artifacts: 'pulldown-cmark/release/*' | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
body: "${{ steps.release_note.outputs.release_note }}" | ||