|
| 1 | +# This GitHub action will publish assets for release when a tag is created |
| 2 | +# that matches the pattern "v*" (ie. v0.1.0). |
| 3 | +# |
| 4 | +# Based on the configuration provided at: |
| 5 | +# https://github.com/hashicorp/terraform-provider-scaffolding |
| 6 | +name: Release dispatch |
| 7 | + |
| 8 | +on: |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + tag: |
| 12 | + required: true |
| 13 | + previous_tag: |
| 14 | + required: true |
| 15 | + project_name: |
| 16 | + default: 'terraform-provider-sci' |
| 17 | + goreleaser_version: |
| 18 | + default: 'v2' |
| 19 | + use_old_key: |
| 20 | + type: boolean |
| 21 | + default: false |
| 22 | + |
| 23 | +# to allow the action to create a release |
| 24 | +permissions: |
| 25 | + contents: write |
| 26 | + |
| 27 | +jobs: |
| 28 | + goreleaser: |
| 29 | + runs-on: ubuntu-latest |
| 30 | + steps: |
| 31 | + - name: Checkout |
| 32 | + uses: actions/checkout@v4 |
| 33 | + with: |
| 34 | + ref: refs/tags/${{ github.event.inputs.tag }} |
| 35 | + |
| 36 | + - name: Unshallow |
| 37 | + run: git fetch --prune --unshallow |
| 38 | + |
| 39 | + - name: Set up Go |
| 40 | + uses: actions/setup-go@v5 |
| 41 | + with: |
| 42 | + go-version-file: 'go.mod' |
| 43 | + cache: true |
| 44 | + |
| 45 | + - name: Import GPG key |
| 46 | + id: import_gpg |
| 47 | + if: ${{ github.event.inputs.use_old_key == 'false' }} |
| 48 | + uses: crazy-max/ghaction-import-gpg@v6.3.0 |
| 49 | + with: |
| 50 | + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} |
| 51 | + passphrase: ${{ secrets.PASSPHRASE }} |
| 52 | + |
| 53 | + - name: Import old GPG key |
| 54 | + id: import_gpg_old |
| 55 | + if: ${{ github.event.inputs.use_old_key == 'true' }} |
| 56 | + uses: crazy-max/ghaction-import-gpg@v6.3.0 |
| 57 | + with: |
| 58 | + gpg_private_key: ${{ secrets.OLD_GPG_PRIVATE_KEY }} |
| 59 | + passphrase: ${{ secrets.OLD_GPG_PASSPHRASE }} |
| 60 | + |
| 61 | + - name: Copy goreleaser config to temp location |
| 62 | + run: cp .goreleaser.yml /tmp/.goreleaser.yml |
| 63 | + |
| 64 | + - name: Override project_name in copied config |
| 65 | + run: yq -i '.project_name = "${{ github.event.inputs.project_name }}"' /tmp/.goreleaser.yml |
| 66 | + |
| 67 | + - name: Run GoReleaser |
| 68 | + uses: goreleaser/goreleaser-action@v6 |
| 69 | + with: |
| 70 | + version: ${{ github.event.inputs.goreleaser_version }} |
| 71 | + args: release --clean --config /tmp/.goreleaser.yml |
| 72 | + env: |
| 73 | + GPG_FINGERPRINT: ${{ github.event.inputs.use_old_key == 'true' && steps.import_gpg_old.outputs.fingerprint || steps.import_gpg.outputs.fingerprint }} |
| 74 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 75 | + GORELEASER_CURRENT_TAG: ${{ github.event.inputs.tag }} |
| 76 | + GORELEASER_PREVIOUS_TAG: ${{ github.event.inputs.previous_tag }} |
0 commit comments