Search code examples
github-actionsgoreleaserterraform-registry

GitHub Release Workflow Is Not Working and Is No Longer Running


I am making a custom terraform provider for my organization. I was following the instructions here:

In the section where it mentions to set up a GitHub Action by copying over the following into my workflows directory:

Unfortunately doing so seems to have caused the release workflow to no longer work and run. As a result, I was hoping I might get some overall insights into this as I am trying to hook it up to terraform registry and it's not letting me publish it because of a mal-release configuration.

Here is the repo:

Here is the code that I am using for release.yml in my existing workflows:

# This GitHub action can publish assets for release when a tag is created.
# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0).
#
# This uses an action (hashicorp/ghaction-import-gpg) that assumes you set your 
# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE`
# secret. If you would rather own your own GPG handling, please fork this action
# or use an alternative one for key handling.
#
# You will need to pass the `--batch` flag to `gpg` in your signing step 
# in `goreleaser` to indicate this is being used in a non-interactive mode.
#
name: release
on:
  push:
    tags:
      - 'v*'
jobs:
  goreleaser:
    runs-on: ubuntu-latest
    steps:
      -
        name: Checkout
        uses: actions/[email protected]
      -
        name: Unshallow
        run: git fetch --prune --unshallow
      -
        name: Set up Go
        uses: actions/setup-go@v2
        with:
          go-version: 1.17
      -
        name: Import GPG key
        id: import_gpg
        uses: hashicorp/[email protected]
        env:
          # These secrets will need to be configured for the repository:
          GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
          PASSPHRASE: ${{ secrets.PASSPHRASE }}
      -
        name: Run GoReleaser
        uses: goreleaser/[email protected]
        with:
          version: latest
          args: release --rm-dist
        env:
          GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
          # GitHub sets this automatically
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

I think it may be the way I am auto-tagging in my repo as well, here is what I am using within my tag.yml:

name: 'tag'
on:
  push:
    branches:
      - main
jobs:
  tag:
    runs-on: ubuntu-latest
    steps:
      - name: 'Checkout'
        uses: actions/[email protected]
      - name: 'Tag'
        uses: anothrNick/[email protected]
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Also, the tag workflow wasn't working at first, but now is, but my release status is just showing no status


Solution

  • So after much chagrin and heartache, I found out why it wasn't working. I didn't specify the Branch on which the action was to be triggered:

    Answer:

    The overall change was adding that to the release.yml. The tag.yml is fine.

    As a result, here was the overall change:

    name: 'release'
    on:
      push:
        branches:
          - main
        tags:
          - 'v*'
    jobs:
    

    And the final release file looked like this:

    # This GitHub action can publish assets for release when a tag is created.
    # Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0).
    #
    # This uses an action (hashicorp/ghaction-import-gpg) that assumes you set your 
    # private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE`
    # secret. If you would rather own your own GPG handling, please fork this action
    # or use an alternative one for key handling.
    #
    # You will need to pass the `--batch` flag to `gpg` in your signing step 
    # in `goreleaser` to indicate this is being used in a non-interactive mode.
    #
    name: 'release'
    on:
      push:
        branches:
          - main
        tags:
          - 'v*'
    jobs:
      goreleaser:
        runs-on: ubuntu-latest
        steps:
          -
            name: Checkout
            uses: actions/[email protected]
          -
            name: Unshallow
            run: git fetch --prune --unshallow
          -
            name: Set up Go
            uses: actions/setup-go@v2
            with:
              go-version: 1.17
          -
            name: Import GPG key
            id: import_gpg
            uses: hashicorp/[email protected]
            env:
              # These secrets will need to be configured for the repository:
              GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
              PASSPHRASE: ${{ secrets.PASSPHRASE }}
          -
            name: Run GoReleaser
            uses: goreleaser/[email protected]
            with:
              version: latest
              args: release --rm-dist
            env:
              GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
              # GitHub sets this automatically
              GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}