Skip to content
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

Moving release process to goreleaser in 0.54.x #708

Closed
wants to merge 1 commit 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
58 changes: 29 additions & 29 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ jobs:
kappreleaser:
name: kapp release
runs-on: ubuntu-latest
# Set permissions of github token. See https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#permissions
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -20,14 +23,15 @@ jobs:
with:
go-version: "1.19.5"

- name: Build kapp Script
run: |
./hack/build-binaries.sh
shasum -a 256 ./kapp-* | tee checksums.txt
echo "# :open_file_folder: Files Checksum" | tee checksums-formatted.txt
echo \`\`\` | tee -a checksums-formatted.txt
cat checksums.txt | tee -a checksums-formatted.txt
echo \`\`\` | tee -a checksums-formatted.txt
- name: Run GoReleaser
# GoReleaser v2.5.0
uses: goreleaser/goreleaser-action@5e15885530fb01d81d1f24e8a6f54ebbd0fed7eb
if: startsWith(github.ref, 'refs/tags/')
with:
version: 0.184.0
args: release --rm-dist --debug ${{ env.SKIP_PUBLISH }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Minikube
run: |
Expand All @@ -39,31 +43,23 @@ jobs:
# Ensure that there is no existing kapp installed
rm -f /tmp/bin/kapp

- name: Add kapp binary to the Path
- name: Run Test cases
run: |
# Build kapp binary
set -e -x
VERSION=`echo ${{ github.ref }} | grep -Eo '[0-9].*'`
./hack/build.sh

# Add binary to the path
mkdir bin
mv kapp bin
echo "$PWD/bin" >> $GITHUB_PATH
echo $GITHUB_PATH
PATH=$PATH:$PWD/bin
echo $PATH

- name: Run test cases
run: |
# Run test cases
./hack/test-external.sh

- name: Upload binaries and create draft Release
uses: softprops/action-gh-release@v1
with:
name: ${{ github.ref_name }}
token: ${{ secrets.GITHUB_TOKEN }}
body_path: ./checksums-formatted.txt
files: |
kapp-*
checksums.txt
draft: true
prerelease: true

- name: Get uploaded release YAML checksum
uses: actions/github-script@v4
- uses: actions/github-script@v4
id: get-checksums-from-draft-release
if: startsWith(github.ref, 'refs/tags/')
with:
Expand Down Expand Up @@ -104,6 +100,7 @@ jobs:
}
}
console.log(checksums)

return `${checksums['kapp-darwin-amd64']} ./kapp-darwin-amd64
${checksums['kapp-darwin-arm64']} ./kapp-darwin-arm64
${checksums['kapp-linux-amd64']} ./kapp-linux-amd64
Expand All @@ -116,8 +113,11 @@ jobs:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: |
set -e -x
cat ./checksums.txt
diff ./checksums.txt <(cat <<EOF
VERSION=`echo ${{ github.ref }} | grep -Eo '[0-9].*'`

./hack/build-binaries.sh "$VERSION" > ./go-checksums
cat ./go-checksums
diff ./go-checksums <(cat <<EOF
${{steps.get-checksums-from-draft-release.outputs.result}}
EOF
)
Expand Down
9 changes: 7 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Make sure to check the documentation at http://goreleaser.com
before:
hooks:
- go fmt ./cmd/... ./pkg/... ./test/...
- go mod vendor
- go mod tidy
builds:
- env:
Expand All @@ -13,6 +15,9 @@ builds:
goarch:
- amd64
- arm64
ignore:
- goos: windows
goarch: arm64
main: ./cmd/kapp
binary: kapp-{{ .Os }}-{{ .Arch }}

Expand Down Expand Up @@ -40,8 +45,8 @@ snapshot:
release:
# Repo in which the release will be created.
github:
owner: vmware-tanzu
name: carvel-kapp
owner: carvel-dev
name: kapp

# If set to true, will not auto-publish the release.
draft: true
Expand Down
6 changes: 4 additions & 2 deletions hack/build-binaries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

set -e -x -u

./hack/build.sh

function get_latest_git_tag {
git describe --tags | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+'
}

VERSION="${1:-`get_latest_git_tag`}"

go fmt ./cmd/... ./pkg/... ./test/...
go mod vendor
go mod tidy

# makes builds reproducible
export CGO_ENABLED=0
LDFLAGS="-X github.com/vmware-tanzu/carvel-kapp/pkg/kapp/version.Version=$VERSION -buildid="
Expand Down