Do not populate GITHUB_TOKEN automatically #75

Closed
opened 2023-03-24 14:47:09 +00:00 by korpa · 5 comments

I want to release to Gitea packages. If I add GITEA_TOKEN to workflow file, goreleaser says, that multiple tokens are found and that it is not allowed. I even tried to set GITHUB_TOKEN to nothing. Sadly this doesn't work as well as this doesn't unset the env var.

name: goreleaser

on:
  push:
    tags: [ v* ]

jobs:
  goreleaser:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - run: git fetch --force --tags
      - uses: actions/setup-go@v3
        with:
          go-version: '>=1.20.1'
      - name: goreleaser
        uses: https://github.com/goreleaser/goreleaser-action@v4
        with:
            distribution: goreleaser
            version: latest
            args: release
        env:
          GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
          GITHUB_TOKEN: ""

Goreleaser error

19
[command]/opt/hostedtoolcache/goreleaser-action/1.16.2/x64/goreleaser release
20
  • starting release...
21
  • loading config file                              file=.goreleaser.yml
22
  • loading environment variables
23
    • using token from "$GITHUB_TOKEN"
24
    • using token from "$GITEA_TOKEN"
25
  ⨯ release failed after 0s                  error=multiple tokens found, but only one is allowed: GITHUB_TOKEN, GITEA_TOKEN
I want to release to Gitea packages. If I add `GITEA_TOKEN` to workflow file, goreleaser says, that multiple tokens are found and that it is not allowed. I even tried to set `GITHUB_TOKEN` to nothing. Sadly this doesn't work as well as this doesn't unset the env var. ```yaml name: goreleaser on: push: tags: [ v* ] jobs: goreleaser: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - run: git fetch --force --tags - uses: actions/setup-go@v3 with: go-version: '>=1.20.1' - name: goreleaser uses: https://github.com/goreleaser/goreleaser-action@v4 with: distribution: goreleaser version: latest args: release env: GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} GITHUB_TOKEN: "" ``` Goreleaser error ``` 19 [command]/opt/hostedtoolcache/goreleaser-action/1.16.2/x64/goreleaser release 20 • starting release... 21 • loading config file file=.goreleaser.yml 22 • loading environment variables 23 • using token from "$GITHUB_TOKEN" 24 • using token from "$GITEA_TOKEN" 25 ⨯ release failed after 0s error=multiple tokens found, but only one is allowed: GITHUB_TOKEN, GITEA_TOKEN ```
env_files:
  # override gitea actions which passes GITHUB_TOKEN to set env var as null
  github_token: /dev/null

could you try the above? It's what I am using for goreleaser

``` env_files: # override gitea actions which passes GITHUB_TOKEN to set env var as null github_token: /dev/null ``` could you try the above? It's what I am using for goreleaser
Author

Sadly, this didn't work. I added this to the end of my .goreleaser.yml. Same error:

19
[command]/opt/hostedtoolcache/goreleaser-action/1.16.2/x64/goreleaser release
20
  • starting release...
21
  • loading config file                              file=.goreleaser.yml
22
  • loading environment variables
23
    • using token from "$GITHUB_TOKEN"
24
    • using token from "$GITEA_TOKEN"
25
  ⨯ release failed after 0s                  error=multiple tokens found, but only one is allowed: GITHUB_TOKEN, GITEA_TOKEN
Sadly, this didn't work. I added this to the end of my `.goreleaser.yml`. Same error: ``` 19 [command]/opt/hostedtoolcache/goreleaser-action/1.16.2/x64/goreleaser release 20 • starting release... 21 • loading config file file=.goreleaser.yml 22 • loading environment variables 23 • using token from "$GITHUB_TOKEN" 24 • using token from "$GITEA_TOKEN" 25 ⨯ release failed after 0s error=multiple tokens found, but only one is allowed: GITHUB_TOKEN, GITEA_TOKEN ```
wolfogre added the
kind
help wanted
label 2023-03-26 07:56:39 +00:00

I've also experience this issue.
I've been unable to unset the token like tried above and as it's done in the gitea/tea project.
The env_files are only used when the token isn't found so it's of no help in this case.

GoReleaser uses the tokens to figure out what service to use and errors if more then one token is available.

So either a way to unset the token would be needed or for GoReleaser to add a way to force a specific service.

Currently there is a PR to add a way to force GoReleaser to use gitea in the works: https://github.com/goreleaser/goreleaser/pull/3910
This came from the following discussion: https://github.com/orgs/goreleaser/discussions/3900

I've also experience this issue. I've been unable to unset the token like tried above and as it's done in the [gitea/tea](https://gitea.com/gitea/tea) project. The `env_files` are only used when the token isn't found so it's of no help in this case. GoReleaser uses the tokens to figure out what service to use and errors if more then one token is available. So either a way to unset the token would be needed or for GoReleaser to add a way to force a specific service. Currently there is a PR to add a way to force GoReleaser to use gitea in the works: https://github.com/goreleaser/goreleaser/pull/3910 This came from the following discussion: https://github.com/orgs/goreleaser/discussions/3900

This has been resolved with the release of GoReleaser v1.17.
By adding the GORELEASER_FORCE_TOKEN it builds and publishes without any problem.

This is my action for reference:

name: GoReleaser

on:
  push:
    # run only against tags
    tags:
      - v*

jobs:
  goreleaser:
    runs-on: ubuntu-latest
    steps:
      - uses: https://github.com/actions/checkout@v3
        with:
          fetch-depth: 0
      - run: git fetch --force --tags
      - name: Setup Go
        uses: https://github.com/actions/setup-go@v4
        with:
          go-version: stable
      - name: Release
        uses: https://github.com/goreleaser/goreleaser-action@v4
        with:
          distribution: goreleaser
          version: latest
          args: release --clean
        env:
          GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
          GORELEASER_FORCE_TOKEN: gitea
This has been resolved with the release of GoReleaser v1.17. By adding the `GORELEASER_FORCE_TOKEN` it builds and publishes without any problem. This is my action for reference: ```yaml name: GoReleaser on: push: # run only against tags tags: - v* jobs: goreleaser: runs-on: ubuntu-latest steps: - uses: https://github.com/actions/checkout@v3 with: fetch-depth: 0 - run: git fetch --force --tags - name: Setup Go uses: https://github.com/actions/setup-go@v4 with: go-version: stable - name: Release uses: https://github.com/goreleaser/goreleaser-action@v4 with: distribution: goreleaser version: latest args: release --clean env: GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} GORELEASER_FORCE_TOKEN: gitea ```
Owner

As a quick follow-up, I've also created https://github.com/goreleaser/goreleaser/pull/3936

As a quick follow-up, I've also created https://github.com/goreleaser/goreleaser/pull/3936
Sign in to join this conversation.
No Milestone
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: gitea/act_runner#75
No description provided.