Skip to content

Commit

Permalink
Merge pull request #7632 from yuxiang-zhang/enable-brew-pr
Browse files Browse the repository at this point in the history
Refactor release workflows
  • Loading branch information
yuxiang-zhang authored Mar 14, 2024
2 parents 22195e4 + 4573609 commit 90e16ce
Show file tree
Hide file tree
Showing 21 changed files with 141 additions and 675 deletions.
6 changes: 1 addition & 5 deletions .goreleaser-local.yaml → .github/.goreleaser-local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ archives:
- id: default
builds:
- default
name_template: "eksctl_{{ .Os }}_{{ .Arch }}"
replacements:
darwin: Darwin
linux: Linux
windows: Windows
name_template: "eksctl_{{ title .Os }}_{{ .Arch }}"
format: tar.gz
format_overrides:
- goos: windows
Expand Down
File renamed without changes.
6 changes: 1 addition & 5 deletions .goreleaser.yml → .github/.goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ archives:
- id: default
builds:
- default
name_template: "eksctl_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
replacements:
darwin: Darwin
linux: Linux
windows: Windows
name_template: "eksctl_{{ title .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
format: tar.gz
format_overrides:
- goos: windows
Expand Down
20 changes: 14 additions & 6 deletions .github/workflows/build-all-distros-nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ jobs:
name: build all distros
runs-on: ubuntu-latest
steps:
# Clean unnecessary files to save disk space
- name: clean unncessary files to save space
- name: Clean unncessary files to save space
run: |
docker rmi `docker images -q`
sudo rm -rf /usr/share/dotnet /etc/mysql /etc/php /etc/sudo apt/sources.list.d
Expand All @@ -19,23 +18,32 @@ jobs:
sudo apt clean
rm --recursive --force "$AGENT_TOOLSDIRECTORY"
df -h
# Free up disk space on Ubuntu
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be #v1.3.1
with:
# This might remove tools that are actually needed, if set to "true" but frees about 6 GB
tool-cache: false
large-packages: true
swap-storage: true

- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
with:
fetch-depth: 0
- name: Setup build environment
uses: ./.github/actions/setup-build
- name: build image

- name: Build image
run: |
EKSCTL_IMAGE_VERSION=${GITHUB_REF#refs/*/} make -f Makefile.docker eksctl-image
- name: build all
- name: Generate artifacts
run: |
make build-all
make generate-always
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 #v5.0.0
with:
version: v1.24.0
args: --config=.github/.goreleaser-local.yaml --snapshot --skip=publish --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18 changes: 0 additions & 18 deletions .github/workflows/publish-release-candidate.yaml

This file was deleted.

46 changes: 0 additions & 46 deletions .github/workflows/publish-release-type.yaml

This file was deleted.

90 changes: 76 additions & 14 deletions .github/workflows/publish-release.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,80 @@
name: publish-release
name: Publish Release per Type (nested jobs)
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
workflow_call:
inputs:
isReleaseCandidate:
required: true
type: boolean
name:
required: true
type: string
secrets:
customToken:
required: true

jobs:
test-and-build:
uses: ./.github/workflows/test-and-build.yaml
publish-release:
name: Publish GitHub release
uses: ./.github/workflows/publish-release-type.yaml
needs: [test-and-build]
with:
isReleaseCandidate: false
name: release
secrets:
githubToken: ${{ secrets.EKSCTLBOT_TOKEN }}
name: ${{ inputs.isReleaseCandidate && 'prerelease' || 'release' }}
runs-on: ubuntu-latest
steps:
- name: Free up disk space
run: |
echo "Available storage:"
df -h && echo
sudo docker image prune --all --force
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL
echo "Available storage:"
df -h
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1

- name: Set variables
id: vars
run: |
if [ -z "${GITHUB_REF_NAME}" ] || [ "${GITHUB_REF_TYPE}" != "tag" ] ; then
echo "Expected a tag push event, skipping release workflow"
exit 1
fi
tag=${GITHUB_REF_NAME}
echo "GORELEASER_CURRENT_TAG=v${tag}" >> $GITHUB_ENV
echo "RELEASE_DESCRIPTION=${tag}" >> $GITHUB_ENV
RELEASE_NOTES_FILE="docs/release_notes/${tag/-rc.*}.md"
echo "RELEASE_NOTES_FILE=${RELEASE_NOTES_FILE}" >> $GITHUB_ENV
if [ ! -f "${RELEASE_NOTES_FILE}" ]; then
echo "Release notes ${RELEASE_NOTES_FILE} not found. Exiting..."
exit 1
fi
# Update eksctl version to release-candidate
echo "PRE_RELEASE_ID=${tag#*-}" >> $GITHUB_OUTPUT
cat .github/.goreleaser.yml .github/.goreleaser.brew.yml > .github/.goreleaser.brew.combined.yml
- name: Setup build environment
uses: ./.github/actions/setup-build

- name: GoReleaser Release
if: ${{ !inputs.isReleaseCandidate }}
uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 #v5.0.0
with:
version: v1.24.0
args: release --clean --timeout 60m --skip=validate --config=.github/.goreleaser.brew.combined.yml --release-notes="${{env.RELEASE_NOTES_FILE}}"
env:
GITHUB_TOKEN: ${{ secrets.customToken }}
PRE_RELEASE_ID:

- name: GoReleaser Release Candidate
if: ${{ inputs.isReleaseCandidate }}
uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 #v5.0.0
with:
version: v1.24.0
args: release --clean --timeout 60m --skip=validate --config=.github/.goreleaser.yaml --release-notes="${{env.RELEASE_NOTES_FILE}}"
env:
GITHUB_TOKEN: ${{ secrets.customToken }}
PRE_RELEASE_ID: ${{steps.vars.outputs.PRE_RELEASE_ID}}

- name: get version
id: get_version
run: echo "version=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
6 changes: 3 additions & 3 deletions .github/workflows/release-candidate.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: Release candidate
name: Trigger Release Candidate

on:
workflow_dispatch: {}

jobs:
rc:
name: Trigger release candidate build
name: Push release candidate tag
runs-on: ubuntu-latest
container: public.ecr.aws/eksctl/eksctl-build:9b3f575ceb1a272a000ca1fbaded0174096a007a
container: public.ecr.aws/eksctl/eksctl-build:79ff6e4d9b5ba7e2bfb962efe2fcb7b2eebc1f2a
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: Release
name: Trigger Release

on:
workflow_dispatch: {}

jobs:
rc:
name: Trigger release build
name: Push release tag
runs-on: ubuntu-latest
container: public.ecr.aws/eksctl/eksctl-build:9b3f575ceb1a272a000ca1fbaded0174096a007a
container: public.ecr.aws/eksctl/eksctl-build:79ff6e4d9b5ba7e2bfb962efe2fcb7b2eebc1f2a
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/start-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Release - Test, build and start publishing
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+*'

jobs:
test-and-build:
uses: ./.github/workflows/test-and-build.yaml
check-tag:
runs-on: ubuntu-latest
outputs:
isRc: ${{ steps.vars.outputs.isRc }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
- name: Set output
id: vars
run: |
case ${GITHUB_REF#refs/*/} in
*-rc.*)
echo 'isRc=true' >> $GITHUB_OUTPUT
;;
*)
echo 'isRc=false' >> $GITHUB_OUTPUT
;;
esac
publish-release-candidate:
name: Publish GitHub release candidate
uses: ./.github/workflows/publish-release.yaml
needs: [test-and-build, check-tag]
with:
isReleaseCandidate: ${{ needs.check-tag.outputs.isRc == 'true' }}
name: release candidate
secrets:
customToken: ${{ secrets.EKSCTLBOT_TOKEN }}
permissions:
contents: write
pull-requests: write
2 changes: 1 addition & 1 deletion .github/workflows/update-generated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
resource: ["coredns", "aws-node"]
name: Update ${{ matrix.resource }} and open PR
runs-on: ubuntu-latest
container: public.ecr.aws/eksctl/eksctl-build:9b3f575ceb1a272a000ca1fbaded0174096a007a
container: public.ecr.aws/eksctl/eksctl-build:79ff6e4d9b5ba7e2bfb962efe2fcb7b2eebc1f2a
env:
GOPRIVATE: ""
steps:
Expand Down
1 change: 0 additions & 1 deletion .requirements
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ github.com/maxbrunsfeld/counterfeiter/v6
github.com/cloudflare/cfssl/cmd/[email protected]
github.com/cloudflare/cfssl/cmd/[email protected]
github.com/golangci/golangci-lint/cmd/golangci-lint
github.com/goreleaser/goreleaser
github.com/onsi/ginkgo/v2/[email protected]
github.com/vektra/mockery/v2
github.com/github-release/github-release
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BUILD_IMAGE=public.ecr.aws/eksctl/eksctl-build:9b3f575ceb1a272a000ca1fbaded0174096a007a
ARG BUILD_IMAGE=public.ecr.aws/eksctl/eksctl-build:79ff6e4d9b5ba7e2bfb962efe2fcb7b2eebc1f2a
FROM $BUILD_IMAGE as build

WORKDIR /src
Expand Down
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ binary: ## Build eksctl binary for current OS and place it at ./eksctl
CGO_ENABLED=0 go build -ldflags "-s -w -X $(version_pkg).gitCommit=$(git_commit) -X $(version_pkg).buildDate=$(build_date)" ./cmd/eksctl


.PHONY: build-all
build-all: generate-always ## Build binaries for Linux, Windows and Mac and place them in dist/
goreleaser --config=.goreleaser-local.yaml --snapshot --skip-publish --rm-dist

clean: ## Remove artefacts or generated files from previous build
rm -rf eksctl eksctl-integration-test

Expand Down Expand Up @@ -83,7 +79,6 @@ endif
.PHONY: lint
lint: ## Run linter over the codebase
golangci-lint run --timeout=30m
@for config_file in $(shell ls .goreleaser*); do goreleaser check -f $${config_file} || exit 1; done

.PHONY: test
test: ## Lint, generate and run unit tests. Also ensure that integration tests compile
Expand Down
3 changes: 1 addition & 2 deletions build/docker/build_image_manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"github.com/cloudflare/cfssl v1.6.4"
"github.com/cloudflare/cfssl v1.6.4"
"github.com/golangci/golangci-lint v1.55.2"
"github.com/goreleaser/goreleaser v1.11.5"
"github.com/onsi/ginkgo/v2 v2.13.2"
"github.com/vektra/mockery/v2 v2.38.0"
"github.com/github-release/github-release v0.10.0"
Expand All @@ -15,5 +14,5 @@
"sigs.k8s.io/mdtoc v1.1.0"
"github.com/vburenin/ifacemaker v1.2.1"
100644 blob d3ad8df01a6d4b3470b73aa0b7b4d1e2393ac1a6 build/docker/Dockerfile
100644 blob 5a6c9ae4c6009fa13d955867f2ff8706038d7110 .requirements
100644 blob 06375e647bf25352987c7d3105252076c8292e4c .requirements
100755 blob c1129ff1ff85ac2c53f908a577675ea59a9325a7 build/scripts/install-build-deps.sh
2 changes: 1 addition & 1 deletion build/docker/image_tag
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9b3f575ceb1a272a000ca1fbaded0174096a007a
79ff6e4d9b5ba7e2bfb962efe2fcb7b2eebc1f2a
21 changes: 0 additions & 21 deletions build/scripts/do-release-candidate.sh

This file was deleted.

Loading

0 comments on commit 90e16ce

Please sign in to comment.