chore: release 0.5.0 #31
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
on: | ||
push: | ||
tags: | ||
- "v*" | ||
name: Release | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
permissions: | ||
contents: write | ||
jobs: | ||
crates_io: | ||
name: Publish to crates.io | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Verify tag matches Cargo.toml version | ||
run: | | ||
CARGO_VERSION=$(grep -m1 version Cargo.toml | cut -d '"' -f2) | ||
TAG_VERSION=${GITHUB_REF#refs/tags/v} | ||
if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then | ||
echo "Version mismatch: Cargo.toml ($CARGO_VERSION) vs Git tag ($TAG_VERSION)" | ||
exit 1 | ||
fi | ||
- name: Publish to crates.io | ||
run: cargo publish --token ${{secrets.CARGO_REGISTRY_TOKEN}} | ||
create_release: | ||
name: Create draft release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Create draft release | ||
run: gh release create ${{ github.ref_name }} --notes "" --draft | ||
build: | ||
name: Build binaries | ||
needs: create_release | ||
runs-on: ${{ matrix.os }} | ||
env: | ||
BUILD_FLAGS: build --release --locked --target ${{ matrix.target }} | ||
ARCHIVE_NAME: fixit-${{ github.ref_name }}-${{ matrix.target }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- os: ubuntu-latest | ||
target: aarch64-unknown-linux-musl | ||
cross: true | ||
- os: ubuntu-latest | ||
target: x86_64-unknown-linux-musl | ||
cross: true | ||
- os: macos-latest | ||
target: x86_64-apple-darwin | ||
cross: false | ||
- os: macos-latest | ||
target: aarch64-apple-darwin | ||
cross: false | ||
steps: | ||
- name: Install cargo-deb | ||
if: matrix.os == 'ubuntu-latest' | ||
run: cargo install cargo-deb | ||
- name: Add Rust target | ||
if: ${{ ! matrix.cross }} | ||
run: rustup target add ${{ matrix.target }} | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Build (cargo) | ||
if: ${{ ! matrix.cross }} | ||
run: cargo $BUILD_FLAGS | ||
- name: Build (cross) | ||
if: ${{ matrix.cross }} | ||
run: | | ||
gh release download --repo 'cross-rs/cross' --pattern 'cross-x86_64-unknown-linux-musl.tar.gz' | ||
tar -xvzf cross-x86_64-unknown-linux-musl.tar.gz | ||
chmod +x ./cross | ||
./cross $BUILD_FLAGS | ||
- name: Upload binary archive | ||
run: | | ||
cp ./target/${{ matrix.target }}/release/fixit . | ||
tar -czvf $ARCHIVE_NAME.tar.gz fixit | ||
cat $ARCHIVE_NAME.tar.gz | shasum -a 256 | cut -d " " -f 1 | tr -d "\n" > $ARCHIVE_NAME.sha256 | ||
gh release upload ${{ github.ref_name }} $ARCHIVE_NAME.{tar.gz,sha256} | ||
- name: Create and upload deb package | ||
if: matrix.os == 'ubuntu-latest' | ||
run: | | ||
cargo deb --target=${{ matrix.target }} --no-build --no-strip | ||
gh release upload ${{ github.ref_name }} ./target/${{ matrix.target }}/debian/*.deb | ||
publish_release: | ||
name: Publish release | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Publish release | ||
run: gh release edit ${{ github.ref_name }} --draft=false | ||
upload_dep_repo: | ||
name: Upload deb repository | ||
runs-on: ubuntu-latest | ||
needs: publish_release | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Publish repository | ||
run: | | ||
mkdir -p _site/ppa | ||
cd _site/ppa | ||
gh release download ${{ github.ref_name }} --pattern '*.deb' | ||
dpkg-scanpackages --multiversion . /dev/null | gzip -9c > Packages.gz | ||
cd ../.. | ||
- name: Upload repository to GitHub Pages | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
path: | ||
./_site | ||
publish_dep_repo: | ||
name: Publish deb repository on GitGub Pages | ||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
runs-on: ubuntu-latest | ||
needs: upload_dep_repo | ||
steps: | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 | ||
update-aur: | ||
name: Update AUR repositories | ||
runs-on: ubuntu-latest | ||
needs: publish_release | ||
strategy: | ||
matrix: | ||
include: | ||
- bin: "" | ||
- bin: "-bin" | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Update AUR | ||
run: | | ||
VERSION=${GITHUB_REF#refs/tags/v} | ||
cargo xtask packaging $VERSION aur${{matrix.bin}} | ||
mkdir -p ~/.ssh | ||
echo "${{ secrets.AUR_SSH_PRIVATE_KEY }}" > ~/.ssh/aur | ||
chmod 600 ~/.ssh/aur | ||
echo "Host aur.archlinux.org" >> ~/.ssh/config | ||
echo " IdentityFile ~/.ssh/aur" >> ~/.ssh/config | ||
echo " User aur" >> ~/.ssh/config | ||
ssh-keyscan -H aur.archlinux.org >> ~/.ssh/known_hosts | ||
git clone ssh://[email protected]/fixit${{ matrix.bin }}.git aur | ||
cp PKGBUILD .SRCINFO aur/ | ||
cd aur | ||
git config user.name "github-actions[bot]" | ||
git config user.email "github-actions[bot]@users.noreply.github.com" | ||
git add PKGBUILD .SRCINFO | ||
git commit -m "chore: release $VERSION" | ||
git push origin master | ||
update-homebrew: | ||
name: Update Homebrew formula | ||
run-on: ubuntu-latest | ||
needs: publish_release | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Update Homebrew formula | ||
VERSION=${GITHUB_REF#refs/tags/v} | ||
git clone https://github.com/eugene-babichenko/homebrew-fixit.git | ||
cargo xtask packaging $VERSION homebrew > ./homebrew-fixit/Formula/fixit.rb | ||
cd homebrew-fixit | ||
git config user.name "github-actions[bot]" | ||
git config user.email "github-actions[bot]@users.noreply.github.com" | ||
git remote set-url origin https://eugene-babichenko:${{ secrets.HOMEBREW_FORMULA_TOKEN }}@github.com/eugene-babichenko/homebrew-fixit.git | ||
git add Formula/fixit.rb | ||
git commit -m "chore: release $VERSION" | ||
git push origin master |