From f5cb9e06a96492ef0cf305c05d93cbb7c4e958e1 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Thu, 22 Dec 2022 10:25:24 +0100 Subject: [PATCH] Add workflow for building release snapshots (#152) Use custom caching because goreleaser performs a cross platform build and therefore we cannot share a cache with the test builds. --- .github/workflows/release-snapshot.yml | 51 ++++++++++++++++++++++++++ .github/workflows/release.yml | 21 ++++++++++- 2 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/release-snapshot.yml diff --git a/.github/workflows/release-snapshot.yml b/.github/workflows/release-snapshot.yml new file mode 100644 index 00000000..543708fc --- /dev/null +++ b/.github/workflows/release-snapshot.yml @@ -0,0 +1,51 @@ +name: release-snapshot + +on: + push: + branches: + - main + + workflow_dispatch: + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout repository and submodules + uses: actions/checkout@v3 + + - name: Unshallow + run: git fetch --prune --unshallow + + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: 1.18.8 + + - name: Locate cache paths + id: cache + run: | + echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT + echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_OUTPUT + + # Note: use custom caching because below performs a cross platform build + # through goreleaser and don't want to share a cache with the test builds. + - name: Setup caching + uses: actions/cache@v3 + with: + path: | + ${{ steps.cache.outputs.GOMODCACHE }} + ${{ steps.cache.outputs.GOCACHE }} + key: release-${{ runner.os }}-go-${{ hashFiles('go.sum', '.goreleaser.yaml') }} + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v4 + with: + version: latest + args: release --snapshot + + - name: Upload assets + uses: actions/upload-artifact@v3 + with: + name: bricks + path: dist/*.zip diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f419c57b..8e1cf370 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,10 +1,12 @@ name: release + on: push: tags: - "v*" + workflow_dispatch: - + jobs: goreleaser: runs-on: ubuntu-latest @@ -19,7 +21,22 @@ jobs: uses: actions/setup-go@v3 with: go-version: 1.18.8 - cache: true + + - name: Locate cache paths + id: cache + run: | + echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT + echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_OUTPUT + + # Note: use custom caching because goreleaser performs a cross platform build + # and therefore we cannot share a cache with the test builds. + - name: Setup caching + uses: actions/cache@v3 + with: + path: | + ${{ steps.cache.outputs.GOMODCACHE }} + ${{ steps.cache.outputs.GOCACHE }} + key: release-${{ runner.os }}-go-${{ hashFiles('go.sum', '.goreleaser.yaml') }} - name: Run GoReleaser uses: goreleaser/goreleaser-action@v3.1.0