Merge pull request #110 from lambdalisue/update-deps #269
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: Build | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
release: | |
types: [published] | |
workflow_dispatch: | |
jobs: | |
build: | |
strategy: | |
matrix: | |
include: | |
- target: aarch64-unknown-linux-gnu | |
os: ubuntu-latest | |
- target: aarch64-unknown-linux-musl | |
os: ubuntu-latest | |
- target: x86_64-unknown-linux-gnu | |
os: ubuntu-latest | |
- target: x86_64-unknown-linux-musl | |
os: ubuntu-latest | |
- target: aarch64-apple-darwin | |
os: macos-latest | |
- target: x86_64-apple-darwin | |
os: macos-latest | |
- target: x86_64-pc-windows-msvc | |
os: windows-latest | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Update local toolchain | |
run: | | |
rustup update | |
- name: Add target | |
run: | | |
rustup target add ${{ matrix.target }} | |
- name: install cross | |
uses: taiki-e/install-action@cross | |
- name: Toolchain info | |
run: | | |
rustc --version | |
cargo --version --verbose | |
cross --version --verbose | |
- name: Build | |
run: | | |
cross build --release --all-features --target ${{ matrix.target }} | |
- name: Rename | |
run: | | |
mv target/${{ matrix.target }}/release/mdbook-alerts ./mdbook-alerts-${{ matrix.target }} | |
if: ${{ runner.os != 'Windows' }} | |
- name: Rename | |
run: | | |
mv target/${{ matrix.target }}/release/mdbook-alerts.exe ./mdbook-alerts-${{ matrix.target }}.exe | |
if: ${{ runner.os == 'Windows' }} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: mdbook-alerts-${{ matrix.target }} | |
path: | | |
./mdbook-alerts-${{ matrix.target }} | |
./mdbook-alerts-${{ matrix.target }}.exe | |
if-no-files-found: error | |
release: | |
if: ${{ github.event_name == 'release' }} | |
needs: [build] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
path: ./artifacts | |
- run: find . | |
- uses: ncipollo/release-action@v1.14.0 | |
with: | |
allowUpdates: true | |
artifactErrorsFailBuild: true | |
artifacts: ./artifacts/mdbook-alerts-*/mdbook-alerts-* | |
removeArtifacts: true | |
publish: | |
if: ${{ github.event_name == 'release' }} | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Update local toolchain | |
run: | | |
rustup update | |
- name: Toolchain info | |
run: | | |
rustc --version | |
cargo --version --verbose | |
- name: Apply version | |
run: | | |
sed -i "s/^version = \"0.0.0\"/version = \"${{ github.event.release.tag_name }}\"/" Cargo.toml | |
sed -i "s/^version = \"v\(.*\)\"/version = \"\1\"/" Cargo.toml | |
- name: Publish (Dry run) | |
run: | | |
cargo publish --allow-dirty --dry-run | |
if: ${{ github.event.release.prerelease == true }} | |
- name: Publish | |
run: | | |
cargo publish --allow-dirty | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
if: ${{ github.event.release.prerelease == false }} |