From 6ecf934719c8bc2ecf979b6b4f8ad908cd70e548 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Wed, 12 Apr 2023 22:16:30 +0200 Subject: [PATCH] Publish snapshot binaries to snapshot release (#329) ## Changes Publish snapshot binaries to the snapshot release at https://github.com/databricks/bricks/releases/tag/snapshot. This means users have a stable URL to find snapshot builds instead of having to navigate to a particular action run. ## Tests Manually. --- .github/workflows/release-snapshot.yml | 32 +++++++++++++++++++++++--- .goreleaser.yaml | 8 ++++++- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-snapshot.yml b/.github/workflows/release-snapshot.yml index a9a1a3232..f23d37e1e 100644 --- a/.github/workflows/release-snapshot.yml +++ b/.github/workflows/release-snapshot.yml @@ -40,6 +40,9 @@ jobs: ${{ steps.cache.outputs.GOCACHE }} key: release-${{ runner.os }}-go-${{ steps.go.outputs.go-version }}-${{ hashFiles('go.sum', '.goreleaser.yaml') }} + - name: Hide snapshot tag to outsmart GoReleaser + run: git tag -d snapshot || true + - name: Run GoReleaser uses: goreleaser/goreleaser-action@v4 with: @@ -51,18 +54,41 @@ jobs: with: name: bricks_darwin_snapshot path: | - dist/bricks_darwin_* + dist/bricks_darwin_*/ - name: Upload Linux binaries uses: actions/upload-artifact@v3 with: name: bricks_linux_snapshot path: | - dist/bricks_linux_* + dist/bricks_linux_*/ - name: Upload Windows binaries uses: actions/upload-artifact@v3 with: name: bricks_windows_snapshot path: | - dist/bricks_windows_* + dist/bricks_windows_*/ + + - name: Update snapshot tag + + # Snapshot release may only be updated for commits to the main branch. + # if: github.ref == 'refs/heads/main' + + run: | + git tag snapshot + git push origin snapshot --force + + - name: Update snapshot release + + # Snapshot release may only be updated for commits to the main branch. + # if: github.ref == 'refs/heads/main' + + uses: softprops/action-gh-release@v1 + with: + name: Snapshot + prerelease: true + tag_name: snapshot + token: ${{ secrets.GITHUB_TOKEN }} + files: | + dist/bricks*.zip diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 0424f4ca9..a3f9616b8 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -44,7 +44,13 @@ builds: binary: '{{ .ProjectName }}' archives: - format: zip - name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}' + + # Include version in archive only for release builds and not for snapshot builds. + # Snapshot archives must have a stable file name such that the artifacts in the nightly + # release are automatically overwritten. If the snapshot version is included in the + # file name then additional logic to clean up older builds would be needed. + name_template: '{{ .ProjectName }}_{{ if not .IsSnapshot }}{{ .Version }}_{{ end }}{{ .Os }}_{{ .Arch }}' + checksum: name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS' algorithm: sha256