Skip to content

publish

publish #1

Workflow file for this run

name: publish
on: workflow_dispatch
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
alias: unknown-linux-gnu
- os: macos-12
alias: x86_64-apple-darwin
- os: macos-13-xlarge
alias: aarch64-apple-darwin
- os: windows-latest
alias: pc-windows-msvc
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- if: matrix.os == 'ubuntu-latest'
name: Install dependencies (linux)
run: |
sudo apt install -y protobuf-compiler
echo "PROTOC=$(which protoc)" >> $GITHUB_ENV
- if: matrix.os == 'macos-12' || matrix.os == 'macos-13-xlarge'
name: Install dependencies (macos)
run: |
brew install protobuf
echo "PROTOC=$(which protoc)" >> $GITHUB_ENV
- if: matrix.sys.os == 'windows-latest'
name: Install MSYS2 (windows)
uses: msys2/setup-msys2@v2
- if: matrix.os == 'windows-latest'
name: Install dependencies (windows)
run: choco install protoc
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Run cargo build
run: cargo build --profile=release-bin
- if: "!cancelled()"
uses: actions/upload-artifact@v4
with:
name: crx-${{ matrix.alias }}
path: target/release-bin/{crx,crx.exe}
if-no-files-found: error
publish:
name: Publish crate
runs-on: [ubuntu-latest]
needs: [build]
if: ${{ always() && !cancelled() && needs.build.result == 'success' }}
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Login to crates.io
run: cargo login $CRATES_IO_TOKEN
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
- name: Publish
run: cargo publish
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
release:
runs-on: [ubuntu-latest]
needs: [build, publish]
if: ${{ always() && !cancelled() && needs.publish.result == 'success' && needs.build.result == 'success' }}
steps:
- uses: actions/download-artifact@v4
with:
path: /artifacts
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
run: |
gh release create "$tag" \
--repo="$GITHUB_REPOSITORY" \
--title="${GITHUB_REPOSITORY#*/} ${tag#v}" \
--generate-notes
gh release upload "$tag" /artifacts