update homebrew formula for v0.0.5 #19
Workflow file for this run
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, Test, and Release | |
on: | |
push: | |
tags: | |
- "v*.*.*" | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
name: Build and Test | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
go-version: ["1.22"] | |
steps: | |
- name: Set up Go ${{ matrix.go-version }} | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Cache Go modules | |
uses: actions/cache@v3 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Get dependencies | |
run: go mod download | |
- name: Build | |
run: make build-all | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: binaries | |
path: build/* | |
retention-days: 1 | |
release: | |
name: Release | |
needs: build | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Get and set tag | |
id: tag | |
run: | | |
tag=$(echo ${GITHUB_REF} | cut -d'/' -f3) | |
echo "tag=${tag}" >> $GITHUB_ENV | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: binaries | |
path: build | |
- name: Generate changelog | |
id: changelog | |
uses: metcalfc/[email protected] | |
with: | |
myToken: ${{ secrets.GITHUB_TOKEN }} | |
- name: Generate checksums | |
run: shasum -a 256 build/* > build/checksums.txt | |
- name: Remove "build/" from each line in checksums.txt | |
run: sed -i -e 's/build\///g' build/checksums.txt | |
- name: Create release | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: build/* | |
name: "Release ${{ env.tag }}" | |
body: ${{ steps.changelog.outputs.changelog }} | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Update Homebrew formula | |
run: | | |
git checkout main | |
git pull origin main | |
# get the sha256 checksum for the binary (macOS arm64) | |
SHA256=$(grep ignore-darwin-arm64-${{ env.tag }} build/checksums.txt | cut -d' ' -f1) | |
# update the formula | |
sed -i 's|url ".*"|url "https://github.com/tasnimzotder/ignore-cli/releases/download/${{ env.tag }}/ignore-darwin-arm64-${{ env.tag }}"|' Formula/ignore-cli.rb | |
sed -i "s/sha256 \".*\"/sha256 \"$SHA256\"/" Formula/ignore-cli.rb | |
sed -i 's/version ".*"/version "${{ env.tag }}"/' Formula/ignore-cli.rb | |
sed -i 's/bin.install ".*" => "ignore"/bin.install "ignore-darwin-arm64-${{ env.tag }}" => "ignore"/' Formula/ignore-cli.rb | |
# commit config changes | |
git config user.name github-actions | |
git config user.email [email protected] | |
git add Formula/ignore-cli.rb | |
git commit -m "update homebrew formula for ${{ env.tag }}" | |
git push origin main | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |