Merge pull request #67 from flownative/task/update-nginx-proxy #103
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 | |
on: | |
push: | |
branches-ignore: | |
- '**' | |
tags: | |
- 'v1.*.*' | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
outputs: | |
darwin_sha256sum: ${{ steps.calculate-checksums-darwin.outputs.darwin_sha256sum }} | |
linux_sha256sum: ${{ steps.calculate-checksums-linux.outputs.linux_sha256sum }} | |
steps: | |
- name: Set up Go 1.19 | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.19 | |
id: go | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v3 | |
- name: Get dependencies | |
run: | | |
go generate -v | |
go install -v | |
- name: Build | |
run: | | |
targets=${@-"darwin/amd64 linux/amd64"} | |
for target in $targets; do | |
os="$(echo $target | cut -d '/' -f1)" | |
arch="$(echo $target | cut -d '/' -f2)" | |
echo "--> Building project for: ${os}/${arch}" | |
GOOS=$os GOARCH=$arch CGO_ENABLED=0 go build -ldflags "-X github.com/flownative/localbeach/pkg/version.Version=${GITHUB_REF#refs/*/}" -o beach . | |
zip "beach_${os}_${arch}.zip" beach | |
ls -la | |
done | |
- name: Archive build result (darwin) | |
uses: actions/upload-artifact@v3 | |
with: | |
name: beach-osx | |
path: beach_darwin_amd64.zip | |
- name: Archive build result (linux) | |
uses: actions/upload-artifact@v3 | |
with: | |
name: beach-linux | |
path: beach_linux_amd64.zip | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
- name: Upload Release Asset (darwin) | |
id: upload-release-asset-macos | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: beach_linux_amd64.zip | |
asset_name: beach_linux_amd64.zip | |
asset_content_type: application/zip | |
- name: Calculate checksum (darwin) | |
id: calculate-checksums-darwin | |
run: echo "darwin_sha256sum=$(sha256sum beach_darwin_amd64.zip | awk '//{print $1}')" >> $GITHUB_OUTPUT | |
- name: Upload Release Asset (linux) | |
id: upload-release-asset-linux | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: beach_darwin_amd64.zip | |
asset_name: beach_darwin_amd64.zip | |
asset_content_type: application/zip | |
- name: Calculate checksum (linux) | |
id: calculate-checksums-linux | |
run: echo "linux_sha256sum=$(sha256sum beach_linux_amd64.zip | awk '//{print $1}')" >> $GITHUB_OUTPUT | |
homebrew: | |
name: Homebrew release | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Check out Go code | |
uses: actions/checkout@v3 | |
- name: Check out Homebrew code | |
uses: actions/checkout@v3 | |
with: | |
repository: flownative/homebrew-flownative | |
path: homebrew | |
- name: Copy formula template | |
run: cp .github/workflows/localbeach.rb.tpl homebrew/Formula/localbeach.rb | |
- name: Set RELEASE_VERSION env | |
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | |
# see: https://github.com/bluwy/substitute-string-action | |
- name: Substitute Homebrew variables | |
uses: bluwy/substitute-string-action@v2 | |
with: | |
_input-file: homebrew/Formula/localbeach.rb | |
_output-file: homebrew/Formula/localbeach.rb | |
_format-key: "{{key}}" | |
version: ${{ env.RELEASE_VERSION }} | |
darwin_sha256sum: ${{ needs.build.outputs.darwin_sha256sum }} | |
linux_sha256sum: ${{ needs.build.outputs.linux_sha256sum }} | |
- name: Commit update | |
run: | | |
cd homebrew | |
git config --local --unset-all "http.https://github.com/.extraheader" | |
git config --global user.email "[email protected]" | |
git config --global user.name "Flownative Bot" | |
git add Formula/localbeach.rb | |
git commit -m 'localbeach: update to ${{ github.ref }}' | |
- name: Push to git | |
uses: ad-m/[email protected] | |
with: | |
github_token: ${{ secrets.FLOWNATIVE_BOT_TOKEN }} | |
repository: flownative/homebrew-flownative | |
directory: homebrew |