From ed74495510c4ce6fb85ff71df464982132710856 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Thu, 17 Oct 2024 15:49:47 -0700 Subject: [PATCH] add naive tap update task --- .github/workflows/build-and-release.yml | 86 +++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 .github/workflows/build-and-release.yml diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml new file mode 100644 index 000000000..c308ed1d5 --- /dev/null +++ b/.github/workflows/build-and-release.yml @@ -0,0 +1,86 @@ +name: Build and Release + +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + include: + - os: ubuntu-latest + goos: linux + goarch: amd64 + - os: macos-latest + goos: darwin + goarch: amd64 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.22' + + - name: Build + run: | + GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o otto8 + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: otto8-${{ matrix.goos }}-${{ matrix.goarch }} + path: otto8 + + release: + runs-on: ubuntu-latest + needs: build + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + path: ./artifacts + + - name: Create Release + uses: softprops/action-gh-release@v2 + with: + files: ./artifacts/** + + update-tap: + runs-on: ubuntu-latest + needs: release + steps: + - name: Checkout tap repository + uses: actions/checkout@v4 + with: + repository: otto8-ai/homebrew-tap + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Calculate SHA256 checksum + id: checksum + run: | + LINUX_SHA256=$(sha256sum ./artifacts/otto8-linux-amd64 | awk '{ print $1 }') + MACOS_SHA256=$(sha256sum ./artifacts/otto8-darwin-amd64 | awk '{ print $1 }') + echo "LINUX_SHA256=$LINUX_SHA256" >> $GITHUB_ENV + echo "MACOS_SHA256=$MACOS_SHA256" >> $GITHUB_ENV + + - name: Update Formula + run: | + cp Formula/otto8.rb.tmpl Formula/otto8.rb + sed -i "s/__LINUX_SHA256__/$LINUX_SHA256/g" Formula/otto8.rb + sed -i "s/__MACOS_SHA256__/$MACOS_SHA256/g" Formula/otto8.rb + sed -i "s/__VERSION__/${{ github.run_number }}/g" Formula/otto8.rb + + - name: Commit and Push changes + run: | + git config user.name "GitHub Actions" + git config user.email "actions@github.com" + git add . + git commit -m "Update otto8 formula to new version" + git push