Skip to content

Merge pull request #72 from flownative/task/update-build #105

Merge pull request #72 from flownative/task/update-build

Merge pull request #72 from flownative/task/update-build #105

Workflow file for this run

name: Build
on:
push:
branches-ignore:
- '**'
tags:
- 'v*.*.*'
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.20
uses: actions/setup-go@v4
with:
go-version: 1.20
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- 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
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: "beach_linux_amd64.zip,beach_darwin_amd64.zip"
artifactContentType: application/zip
generateReleaseNotes: true
makeLatest: true
name: Release ${{ github.ref }}
- name: Calculate checksum (darwin)
id: calculate-checksums-darwin
run: echo "darwin_sha256sum=$(sha256sum beach_darwin_amd64.zip | awk '//{print $1}')" >> $GITHUB_OUTPUT
- 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@v4
- name: Check out Homebrew code
uses: actions/checkout@v4
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 "ops@flownative.com"
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/github-push-action@master
with:
github_token: ${{ secrets.FLOWNATIVE_BOT_TOKEN }}
repository: flownative/homebrew-flownative
directory: homebrew