|
| 1 | +name: Release (and build Golang binaries) |
| 2 | +# This workflow should eventually replace the one in release.yml completely. |
| 3 | + |
| 4 | +permissions: |
| 5 | + contents: "write" |
| 6 | + |
| 7 | +# Eventually this workflow will only be run when a |
| 8 | +#on: |
| 9 | +# push: |
| 10 | +# tags: |
| 11 | +# - 'v[0-9]+.*' |
| 12 | +# Typically we'd only want to build binaries and a release when a new tag is |
| 13 | +# pushed. But since this is a new projectu I'm doing it on every new commit to |
| 14 | +# the master branch. This will make it easy to download and test binaries for |
| 15 | +# each new version. |
| 16 | +on: |
| 17 | + push: |
| 18 | + branches: |
| 19 | + - master |
| 20 | + |
| 21 | +# TODO: Uncomment once this is merged and we're ready to prepare the first |
| 22 | +# public tagged version of the Golang implementation. |
| 23 | +#jobs: |
| 24 | +# release: |
| 25 | +# runs-on: ubuntu-latest |
| 26 | +# steps: |
| 27 | +# - uses: GoogleCloudPlatform/release-please-action@v4 |
| 28 | +# name: create release |
| 29 | +# with: |
| 30 | +# release-type: simple |
| 31 | +# bump-minor-pre-major: true # remove this to enable breaking changes causing 1.0.0 tag |
| 32 | +# changelog-types: | |
| 33 | +# [ |
| 34 | +# { "type": "feat", "section": "Features", "hidden": false }, |
| 35 | +# { "type": "fix", "section": "Patches", "hidden": false }, |
| 36 | +# { "type": "docs", "section": "Documentation", "hidden": false } |
| 37 | +# ] |
| 38 | +# extra-files: | |
| 39 | +# SECURITY.md |
| 40 | +# docs/guide/getting-started.md |
| 41 | +# docs/pt-br/guide/getting-started.md |
| 42 | +# docs/zh-hans/guide/getting-started.md |
| 43 | + |
| 44 | +jobs: |
| 45 | + |
| 46 | + create-release: |
| 47 | + name: create-release |
| 48 | + runs-on: ubuntu-22.04 |
| 49 | + # env: |
| 50 | + # Set to force version number, e.g., when no tag exists. |
| 51 | + # ASDF_VERSION: TEST-0.1.0 |
| 52 | + outputs: |
| 53 | + upload_url: ${{ steps.release.outputs.upload_url }} |
| 54 | + asdf_version: ${{ env.ASDF_VERSION }} |
| 55 | + steps: |
| 56 | + - name: Get the release version from the tag |
| 57 | + shell: bash |
| 58 | + if: env.ASDF_VERSION == '' |
| 59 | + run: | |
| 60 | + # Apparently, this is the right way to get a tag name. Really? |
| 61 | + # |
| 62 | + # See: https://github-proxy.voidd.workers.devmunity/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027 |
| 63 | + #echo "ASDF_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV |
| 64 | + echo "ASDF_VERSION=$GITHUB_SHA" >> "$GITHUB_ENV" |
| 65 | + echo "version is: ${{ env.ASDF_VERSION }}" |
| 66 | + - uses: actions/checkout@v3 |
| 67 | + - name: Create GitHub release |
| 68 | + id: release |
| 69 | + uses: ncipollo/release-action@v1 |
| 70 | + env: |
| 71 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 72 | + with: |
| 73 | + tag: ${{ env.ASDF_VERSION }} |
| 74 | + name: ${{ env.ASDF_VERSION }} |
| 75 | + |
| 76 | + build: |
| 77 | + runs-on: ubuntu-latest |
| 78 | + steps: |
| 79 | + - |
| 80 | + name: Checkout |
| 81 | + uses: actions/checkout@v4 |
| 82 | + with: |
| 83 | + fetch-depth: 0 |
| 84 | + - |
| 85 | + name: Set up Go |
| 86 | + uses: actions/setup-go@v4 |
| 87 | + with: |
| 88 | + go-version: '1.21.5' |
| 89 | + - |
| 90 | + name: Run GoReleaser |
| 91 | + uses: goreleaser/goreleaser-action@v5 |
| 92 | + with: |
| 93 | + # either 'goreleaser' (default) or 'goreleaser-pro' |
| 94 | + distribution: goreleaser |
| 95 | + version: latest |
| 96 | + args: release --clean |
| 97 | + env: |
| 98 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments