Skip to content

feat: Transparent release process #480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release

on:
push:
tags:
- '*'

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check versions
run: |
version=$(grep "^version:" plugin.yaml | cut -d '"' -f 2)
if [ "${GITHUB_REF_NAME}" != "v${version}" ]; then
echo '::error::Version mismatch'
exit 1
fi
- uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
- uses: goreleaser/goreleaser-action@v4
with:
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ release/
.envrc
.idea
docker-run-release-cache/
dist/
51 changes: 51 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
# Make sure to check the documentation at https://goreleaser.com
before:
hooks:
# Keep mod files clean
- go mod tidy -v

builds:
- main: main.go
binary: bin/diff
env:
- CGO_ENABLED=0
flags: -trimpath
ldflags: -s -w -X {{ .ModulePath }}/cmd.Version={{ .Version }}
targets:
# helm supported targets
# https://github.com/helm/helm/blob/main/Makefile#L4C1-L4C1
- darwin_amd64
- darwin_arm64
- linux_386
- linux_amd64
- linux_arm
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm not missing anything, we can safely omit 386, arm, ppc64le and s390x "yet" as we don't publish binaries for those archs today.

Copy link
Author

@bonddim bonddim Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just included all architectures supported by Helm.
Yes, its safe to omit them, but why to not include them now?

- linux_arm64
- linux_ppc64le
- linux_s390x
- windows_amd64
# additional targets
- freebsd_amd64

archives:
- format: tgz
name_template: '{{ .ProjectName }}-{{ tolower .Os }}-{{ .Arch }}'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct - I missed this.

wrap_in_directory: diff
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need this wrapping, because our installation script doesn't expect it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All files in latest release are wrapped into diff directory, and installation script uses it :

HELM_TMP_BIN="$HELM_TMP/diff/bin/diff"

Copy link
Collaborator

@mumoshu mumoshu Jan 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are absolutely correct @bonddim! Thank you very much for the confirmation and the correction. You saved the day!

files:
- README.md
- LICENSE
- plugin.yaml

checksum:
name_template: 'checksums.txt'

snapshot:
name_template: '{{ incpatch .Version }}-{{ .ShortCommit }}'

changelog:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed this in my PR so let me check later!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't required for releases, but I like this snapshot versioning

sort: asc
filters:
exclude:
- '^chore:'
- '^docs:'
- '^test:'
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ dist:
tar -C build/ -zcvf $(CURDIR)/release/helm-diff-windows-amd64.tgz diff/

.PHONY: release
release: lint dist
release: lint
scripts/release.sh v$(VERSION)

# Test for the plugin installation with `helm plugin install -v THIS_BRANCH` works
Expand Down
1 change: 0 additions & 1 deletion scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ fi

git tag $1
git push origin $1
gh release create $1 --draft --generate-notes --title "$1" release/*.tgz
Copy link
Collaborator

@mumoshu mumoshu Jan 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Today, the release process looks like the below:

  • Add a commit that updates plugin.yaml to have a new version
  • Run this release.sh

After this and #517, the process would look like:

  • Add a commit that updates plugin.yaml to have a new version
  • Run this script, or create a semver tag along with the release on the GitHub web UI
  • The workflow gets triggered on GHA. goreleaser does the rest.

I guess we'd rather prefer the below:

  • Add a commit that updates plugin.yaml to have a new version
  • A GHA workflow reads the new plugin.yaml version value and tags the commit with the version
  • The release workflow gets triggered and goreleaser does the rest.

Maybe we can modify this release.sh to do the second bullet point?
Basically, we can deduce $1 here from plugin.yml by reading the version field using eg. yq? 🤔