diff --git a/.drone.yml b/.drone.yml index 42f66ed3..c0e312d9 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: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6211808e..841ac1bd 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,40 @@ jobs: - name: Checkout code uses: actions/checkout@v4 with: - ref: ${{ github.ref_name}} - - name: Build operator binary - run: | - make operator + fetch-depth: 0 + ref: ${{ github.ref_name }} - 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..ccdd49a0 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,27 @@ +version: 2 + +project_name: gke-operator + +before: + hooks: + - go mod tidy + +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + goarch: + - amd64 + - arm64 + binary: gke-operator + +release: + prerelease: auto + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:"