Merge pull request #381 from stanfrbd/stanfrbd/blog-post #413
This file contains hidden or 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: Rolling Release | |
| on: | |
| push: | |
| branches: | |
| - master | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| if: github.repository == 'asciimoo/hister' | |
| name: GoReleaser rolling build | |
| runs-on: ubuntu-latest | |
| container: | |
| image: goreleaser/goreleaser-cross:v1.25.5 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: 'stable' | |
| - name: Set up Node | |
| uses: actions/setup-node@v6.4.0 | |
| with: | |
| node-version: latest | |
| # Mark the checkout as 'safe' despite being owned by `root` | |
| - run: git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
| - run: git config --global --add safe.directory "$(pwd)" | |
| - name: Generate front-end | |
| run: go generate ./... | |
| - name: Run GoReleaser | |
| uses: goreleaser/goreleaser-action@master | |
| with: | |
| distribution: goreleaser | |
| version: latest | |
| args: build --snapshot --clean | |
| - name: Force Update 'Rolling' Tag | |
| run: | | |
| git tag -f rolling | |
| git push origin rolling --force | |
| - name: Generate release body | |
| id: release_body | |
| run: | | |
| echo "body<<EOF" >> $GITHUB_OUTPUT | |
| echo "Automated build from master." >> $GITHUB_OUTPUT | |
| echo "Commit: ${{ github.sha }}" >> $GITHUB_OUTPUT | |
| echo "Built on: $(date -u '+%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| # this is super ugly - produces: | |
| # dist/hister_cgo_windows_amd64.exe from dist/build_cgo_windows_amd64_v1/hister.exe | |
| # dist/hister_cgo_darwin_arm64 from dist/hister_cgo_darwin_arm64_v8.0/hister | |
| # and so on.. | |
| - name: Clean-up dist dir | |
| run: | | |
| for i in dist/*/hister*; do mv $i `echo "$i" | sed "s/build/hister/" | sed "s/_v[0-9].\+hister//"`; done | |
| rm dist/metadata.json dist/artifacts.json dist/config.yaml | |
| - name: Update Latest Release | |
| uses: softprops/action-gh-release@v3.0.0 | |
| with: | |
| tag_name: rolling | |
| name: 'Hister (Dev Build)' | |
| body: ${{ steps.release_body.outputs.body }} | |
| prerelease: true | |
| make_latest: true | |
| files: | | |
| dist/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |