|
| 1 | +name: Release |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + pull_request: |
| 7 | + paths: |
| 8 | + # Go |
| 9 | + - "**" |
| 10 | + - "!**.md" |
| 11 | + - ".goreleaser" |
| 12 | + - "go.*" |
| 13 | + - "**.go" |
| 14 | + # CI |
| 15 | + - ".github/workflows/release.yml" |
| 16 | + |
| 17 | +jobs: |
| 18 | + semantic-release: |
| 19 | + name: Semantic release |
| 20 | + runs-on: ubuntu-latest |
| 21 | + outputs: |
| 22 | + new-release-published: ${{ steps.semantic-echo.outputs.new-release-published }} |
| 23 | + release-version: ${{ steps.semantic-echo.outputs.release-version }} |
| 24 | + steps: |
| 25 | + - name: Checkout |
| 26 | + uses: actions/checkout@v3 |
| 27 | + |
| 28 | + - name: Unshallow |
| 29 | + run: git fetch --prune --unshallow |
| 30 | + |
| 31 | + - name: Run Semantic Release |
| 32 | + id: semantic |
| 33 | + uses: docker://ghcr.io/codfish/semantic-release-action:v1 |
| 34 | + with: |
| 35 | + branches: | |
| 36 | + ['master'] |
| 37 | + plugins: | |
| 38 | + [ |
| 39 | + '@semantic-release/commit-analyzer', |
| 40 | + '@semantic-release/release-notes-generator', |
| 41 | + '@semantic-release/github' |
| 42 | + ] |
| 43 | + env: |
| 44 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 45 | + |
| 46 | + - name: Export Semantic Release |
| 47 | + id: semantic-echo |
| 48 | + run: | |
| 49 | + echo "::set-output name=new-release-published::${{steps.semantic.outputs.new-release-published}}" |
| 50 | + echo "::set-output name=release-version::${{steps.semantic.outputs.release-version}}" |
| 51 | +
|
| 52 | + post-semantic-release: |
| 53 | + needs: semantic-release |
| 54 | + #if: needs.semantic-release.outputs.new-release-published == 'true' |
| 55 | + runs-on: ubuntu-latest |
| 56 | + steps: |
| 57 | + - name: Checkout |
| 58 | + uses: actions/checkout@v3 |
| 59 | + |
| 60 | + - name: Unshallow |
| 61 | + run: git fetch --prune --unshallow |
| 62 | + |
| 63 | + - name: Setup asdf |
| 64 | + uses: asdf-vm/actions/setup@v1 |
| 65 | + |
| 66 | + - name: Setup go |
| 67 | + run: | |
| 68 | + asdf plugin add golang |
| 69 | + asdf install golang |
| 70 | +
|
| 71 | + - name: Register version on pkg.go.dev |
| 72 | + if: needs.semantic-release.outputs.new-release-published == 'true' |
| 73 | + run: | |
| 74 | + package=$(cat go.mod | grep ^module | awk '{print $2}') |
| 75 | + version=v${{ needs.semantic-release.outputs.release-version }} |
| 76 | + url=https://proxy.golang.org/${package}/@v/${version}.info |
| 77 | + set -x +e |
| 78 | + curl -i $url |
0 commit comments