Skip to content

Commit

Permalink
ci(goreleaser): fix release candidate suffix (backport #3833) (#3838)
Browse files Browse the repository at this point in the history
Prevents #3819 from
happening again. Also adds a document so other maintainers can generate
+ upload prebuilt binaries if they don't work again in the future.

The current `-rc*`
[prerelease_suffix](https://goreleaser.com/customization/git/#git) was
not working because goreleaser treated v2.1.2-rc1 as more recent than
v2.1.2 in the [failing
workflow](https://github.com/celestiaorg/celestia-app/actions/runs/10523365886/job/29157983992#step:6:68).
This resolves by removing the `*`.

## Testing

1. Worked on my fork:
https://github.com/rootulp/celestia-app/releases/tag/v2.1.2
2. Worked on this repo:
https://github.com/celestiaorg/celestia-app/releases/tag/v2.1.2

### Before

```
    • git state                                      commit=48173df3dc78f9348eedb3796f29ef9e9e5dc584 branch=HEAD current_tag=v2.1.2-rc1 previous_tag=v2.1.2-rc0 dirty=true
```
### After

```
    • git state                                      commit=48173df3dc78f9348eedb3796f29ef9e9e5dc584 branch=HEAD current_tag=v2.1.2 previous_tag=v2.1.2-rc0 dirty=true
```

It is curious that it thinks the previous tag is v2.1.2-rc0 and not
v2.1.2-rc1 but I couldn't fix with various
[tag_sort](https://goreleaser.com/customization/git/?h=tag_sort#git)
options. I think this only impacts Goreleaser changelog generation which
we don't use b/c we use Github's auto generate release notes
feature.<hr>This is an automatic backport of pull request #3833 done by
[Mergify](https://mergify.com).

Co-authored-by: Rootul P <[email protected]>
  • Loading branch information
mergify[bot] and rootulp committed Sep 3, 2024
1 parent 48173df commit 0fe3a2c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,4 @@ changelog:
release:
prerelease: auto
git:
prerelease_suffix: "-rc*"
prerelease_suffix: "-rc"
49 changes: 49 additions & 0 deletions docs/maintainers/prebuilt-binaries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Prebuilt binaries

Prebuilt binaries are attached to each release via [GoReleaser](https://goreleaser.com/) which runs in Github Actions. If GoReleaser failed to attach prebuilt binaries, you may want to attach them manually by following the steps below.

## Prerequisites

1. Create a Github token (classic) that has `repo:public_repo` scope via: <https://github.com/settings/tokens/new>

```shell
export GORELEASER_ACCESS_TOKEN=<your-github-token>
echo "GITHUB_TOKEN=${GORELEASER_ACCESS_TOKEN}" >> .release-env
```

## Steps

1. [Optional] If you need to make any code changes to fix the issue that occured when CI tried to generate and attach the prebuilt binaries, then you likely need to skip validation when running GoReleaser locally. To skip validation, modify the Makefile command like so:

```diff
## prebuilt-binary: Create prebuilt binaries and attach them to GitHub release. Requires Docker.
prebuilt-binary:
@if [ ! -f ".release-env" ]; then \
echo "A .release-env file was not found but is required to create prebuilt binaries. This command is expected to be run in CI where a .release-env file exists. If you need to run this command locally to attach binaries to a release, you need to create a .release-env file with a Github token (classic) that has repo:public_repo scope."; \
exit 1;\
fi
docker run \
--rm \
-e CGO_ENABLED=1 \
--env-file .release-env \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-w /go/src/$(PACKAGE_NAME) \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
- release --clean
+ release --clean --skip=validate
.PHONY: prebuilt-binary
```

1. Before proceeding, test your change by running `make prebuilt-binary` and verifying that prebuilt binaries are attached to a release on your Github fork.
1. Modify `.goreleaser.yaml` so that you can upload assets to the main repository:

```diff
release:
+ github:
+ owner: celestiaorg
+ name: celestia-app
```

1. Run `make prebuilt-binary` to generate and attach the prebuilt binaries.
1. Verify the assets were attached to the release on the main repository.

0 comments on commit 0fe3a2c

Please sign in to comment.