name: Release
permissions:
contents: write
id-token: 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 == 'hpehl'
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 == 'hpehl'
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 == 'hpehl'
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: aarch64-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: depup
target: ${{ matrix.target }}
token: ${{ secrets.GITHUB_TOKEN }}
update-formula:
if: github.repository_owner == 'hpehl'
needs: upload-assets
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- id: get-version
uses: battila7/get-version-action@v2.3.0
- id: checksums
run: |
VERSION=${{steps.get-version.outputs.version}}
BASE_URL="https://github.com/hpehl/depup/releases/download/${VERSION}"
SHA_ARM=$(wget -qO- "${BASE_URL}/depup-aarch64-apple-darwin.tar.gz" | shasum -a 256 | head -c 64)
SHA_INTEL=$(wget -qO- "${BASE_URL}/depup-x86_64-apple-darwin.tar.gz" | shasum -a 256 | head -c 64)
echo "sha_arm=${SHA_ARM}" >> "$GITHUB_OUTPUT"
echo "sha_intel=${SHA_INTEL}" >> "$GITHUB_OUTPUT"
- 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
VERSION=${{steps.get-version.outputs.version}}
VERSION_NUM=${{steps.get-version.outputs.version-without-v}}
BASE_URL="https://github.com/hpehl/depup/releases/download/${VERSION}"
sed -i 's|version ".*"|version "'"${VERSION_NUM}"'"|' Formula/depup.rb
sed -i '/on_arm do/,/end/{s|url ".*"|url "'"${BASE_URL}/depup-aarch64-apple-darwin.tar.gz"'"|;s|sha256 ".*"|sha256 "'"${{steps.checksums.outputs.sha_arm}}"'"|;}' Formula/depup.rb
sed -i '/on_intel do/,/end/{s|url ".*"|url "'"${BASE_URL}/depup-x86_64-apple-darwin.tar.gz"'"|;s|sha256 ".*"|sha256 "'"${{steps.checksums.outputs.sha_intel}}"'"|;}' Formula/depup.rb
- name: Commit and push changes
env:
TOKEN: ${{ secrets.FORMULA_TOKEN }}
run: |
cd homebrew-tap
git add Formula/depup.rb
git commit -m "Update depup formula: version ${{steps.get-version.outputs.version-without-v}}"
git push origin main