name: Release
permissions:
contents: write
on:
push:
tags:
- v[0-9]+.*
env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
CARGO_TERM_COLOR: always
RUST_BACKTRACE: full
RUSTFLAGS: -D warnings
RUSTUP_MAX_RETRIES: 10
defaults:
run:
shell: bash --noprofile --norc -CeEuxo pipefail {0}
jobs:
create-release:
if: github.repository_owner == 'model-graph-tools'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: taiki-e/create-gh-release-action@v1.11.0
with:
title: '$version'
changelog: CHANGELOG.md
token: ${{ secrets.GITHUB_TOKEN }}
publish-crate:
if: github.repository_owner == 'model-graph-tools'
needs: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- run: cargo publish --token ${CRATES_TOKEN}
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
upload-assets:
if: github.repository_owner == 'model-graph-tools'
needs: create-release
name: ${{ matrix.target }}
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-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@v6
- uses: taiki-e/upload-rust-binary-action@v1
with:
bin: mgt
target: ${{ matrix.target }}
token: ${{ secrets.GITHUB_TOKEN }}
update-formula:
if: github.repository_owner == 'model-graph-tools'
needs: upload-assets
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- id: get-version
uses: battila7/get-version-action@v2.3.0
- id: checksum
run: |
echo ::set-output name=sha::"$(wget -qO- https://github.com/model-graph-tools/tooling/releases/download/${{steps.get-version.outputs.version}}/mgt-x86_64-apple-darwin.tar.gz | shasum -a 256 | head -c 64)"
- name: Set up Git identity
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Clone homebrew-tap
env:
TOKEN: ${{ secrets.FORMULA_TOKEN }}
run: |
git clone https://$TOKEN@github.com/hpehl/homebrew-tap.git
cd homebrew-tap
git checkout main
- name: Update formula
run: |
cd homebrew-tap
sed -i 's|url ".*"|url "https://github.com/model-graph-tools/tooling/releases/download/${{steps.get-version.outputs.version}}/mgt-x86_64-apple-darwin.tar.gz"|' Formula/mgt.rb
sed -i 's|sha256 ".*"|sha256 "${{steps.checksum.outputs.sha}}"|' Formula/mgt.rb
sed -i 's|version ".*"|version "${{steps.get-version.outputs.version-without-v}}"|' Formula/mgt.rb
- name: Commit and push changes
env:
TOKEN: ${{ secrets.FORMULA_TOKEN }}
run: |
cd homebrew-tap
git add Formula/mgt.rb
git commit -m "Update mgt formula: version ${{steps.get-version.outputs.version-without-v}}"
git push origin main