Skip to main content

Using Goreleaser with ForgeJo

·322 words·2 mins
Goreleaser ForgeJo Go
Mike Bell
Author
Mike Bell

For my resound app I wanted a really nice release process (it is after all part of my job!). Resound is a cli go app built with Cobra and Viper, it takes the last RSS item and posts it to Mastodon, pretty simple. You can checkout the latest version here. I’m using goreleaser to build multiple architectures and then push them to my ForgeJo instance here’s how I did it because there are a lot of moving parts you have to put together in order to get it working.

tldr;
#

ForgeJo Action
#

- name: Run GoReleaser
        uses: https://github.com/goreleaser/goreleaser-action@ec59f474b9834571250b370d4735c50f8e2d1e29 # v7
        with:
          # either 'goreleaser' (default) or 'goreleaser-pro'
          distribution: goreleaser
          # 'latest', 'nightly', or a semver
          version: '~> v2'
          args: release --clean
        env:
          GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Important part here is the make sure uses: uses the FQDN of the action and that your passing in GITEA_TOKEN from your repo secrets. I have the following token with these options scope to the repo:

  • write:package
  • write:repository

Note: this can probably be scoped even smaller.

.goreleaser.yaml
#

You can view the full version in the tldr above but here are the important parts:

release:
  gitea:
    owner: mikebell
    name: resound
  footer: >-

You have to set the owner and repo name under gitea in release. This tells goreleaser where to put the output.

gitea_urls:
  api: https://code.remotelab.uk/api/v1
  download: https://code.remotelab.uk

You then have to define your ForgeJo instance, goreleaser doesn’t officially support ForgeJo but the api is compatible with gitea.

force_token: gitea

I then had to force the token to gitea because goreleaser automatically tries to work out which forge your using and there’s already a GITHUB_TOKEN passed by default.


Once I had all this in place I can create a tag from either the ForgeJo UI or through git and my action will create the packages and upload them to a new release you can see 1.1.0 of resound here.

Hope this helps.