From 573236d2e52aff434797e431ba44f76e2e399ded Mon Sep 17 00:00:00 2001 From: yiannistri <8741709+yiannistri@users.noreply.github.com> Date: Wed, 3 Jul 2024 16:12:29 +0100 Subject: [PATCH 1/2] ci: Add goreleaser config and update release workflow --- .github/workflows/release.yaml | 41 +++++++++++++++++++++++++--------- .goreleaser.yaml | 27 ++++++++++++++++++++++ 2 files changed, 58 insertions(+), 10 deletions(-) create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6211808e..4a6ebe99 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -15,15 +15,12 @@ on: # - PUBLIC_REGISTRY_USERNAME # - PUBLIC_REGISTRY_PASSWORD -permissions: - contents: read - jobs: - publish-public: + release: permissions: - contents: read - id-token: write - runs-on: ubuntu-22.04 + contents: write # required for creating GH release + id-token: write # required for reading vault secrets + runs-on: ubuntu-latest steps: - name: Read secrets uses: rancher-eio/read-vault-secrets@main @@ -44,15 +41,39 @@ jobs: - name: Checkout code uses: actions/checkout@v4 with: + fetch-depth: 0 ref: ${{ github.ref_name}} - - name: Build operator binary - run: | - make operator - name: Build and push all image variations run: | + make operator make image-push TAG="${TAG}-amd64" TARGET_PLATFORMS=linux/amd64 make image-push TAG="${TAG}-arm64" TARGET_PLATFORMS=linux/arm64 make image-push env: TAG: ${{ github.ref_name }} REPO: ${{ vars.PUBLIC_REGISTRY }}/${{ vars.PUBLIC_REGISTRY_REPO }} + - name: Create release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required for creating GH release + id: goreleaser + uses: goreleaser/goreleaser-action@v6 + with: + distribution: goreleaser + version: "~> v2" + args: release --clean --verbose + - name: Upload charts to release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required for updating GH release + TAG: ${{ github.ref_name }} # image tag to be referenced in `values.yaml` of the Helm chart release + run: | + version=$(echo '${{ steps.goreleaser.outputs.metadata }}' | jq -r '.version') + echo "Publishing helm charts (version: $version)" + + # Both version and appVersion are set to the same value in the Chart.yaml (excluding the 'v' prefix) + CHART_VERSION=$version GIT_TAG=$version make charts + + for f in $(find bin/ -name '*.tgz'); do + echo "Uploading $f to GitHub release $TAG" + gh release upload $TAG $f + done + echo "Charts successfully uploaded to GitHub release $TAG" diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 00000000..ea1684a0 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,27 @@ +version: 2 + +project_name: aks-operator + +before: + hooks: + - go mod tidy + +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + goarch: + - amd64 + - arm64 + binary: aks-operator + +release: + prerelease: auto + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" \ No newline at end of file From efe0553589c318d515146ae57a96e2f4e1f39a7c Mon Sep 17 00:00:00 2001 From: yiannistri <8741709+yiannistri@users.noreply.github.com> Date: Wed, 3 Jul 2024 16:21:39 +0100 Subject: [PATCH 2/2] chore: Remove Drone configuration --- .drone.yml | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/.drone.yml b/.drone.yml index 8c9de02f..0eb3eb33 100644 --- a/.drone.yml +++ b/.drone.yml @@ -20,25 +20,6 @@ steps: - pull_request - tag -- name: github_binary_release - image: plugins/github-release - settings: - api_key: - from_secret: github_token - prerelease: true - checksum: - - sha256 - checksum_file: CHECKSUMsum-amd64.txt - checksum_flatten: true - files: - - "dist/artifacts/*" - when: - ref: - - refs/head/master - - refs/tags/* - event: - - tag - - name: docker-publish image: plugins/docker settings: @@ -92,25 +73,6 @@ steps: - pull_request - tag -- name: github_binary_release - image: plugins/github-release - settings: - api_key: - from_secret: github_token - prerelease: true - checksum: - - sha256 - checksum_file: CHECKSUMsum-arm64.txt - checksum_flatten: true - files: - - "dist/artifacts/*" - when: - ref: - - refs/head/master - - refs/tags/* - event: - - tag - - name: docker-publish image: plugins/docker settings: