From 06d0fccc3c49d987f01ec2d92466ec1ee1fbf28d Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Mon, 11 Apr 2022 20:56:57 -0700 Subject: [PATCH] Update release step in CI --- .github/workflows/ci.yml | 49 +++++++++++++++++++++++++++++----- .github/workflows/release.yaml | 2 +- 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6674807365..6d7e01973d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -279,13 +279,50 @@ jobs: uses: actions/setup-go@v3 with: go-version: ${{ needs.checks.outputs.go_version }} - - name: Publish Release Notes on new tag - uses: release-drafter/release-drafter@v5 + + - uses: actions/setup-node@v3 + - run: npm install js-yaml + continue-on-error: true + if: startsWith(github.ref, 'refs/tags/') + - name: Publish release on tag + uses: actions/github-script@v6 + continue-on-error: true with: - publish: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - if: ${{ startsWith(github.ref, 'refs/tags/') }} + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const ref = context.ref.split("/")[2] + const yaml = require('js-yaml'); + + const releases = (await github.rest.repos.listReleases({ + owner: context.payload.repository.owner.login, + repo: context.payload.repository.name, + per_page: 100, + })).data + + const draft_release = releases.find(release => release.draft && release.tag_name === ref) + + const helm_file = (await github.rest.repos.getContent({ + owner: context.payload.repository.owner.login, + repo: context.payload.repository.name, + path: "deployments/helm-chart/Chart.yaml", + ref: ref, + })).data.content + + const helm_yaml = yaml.load(Buffer.from(helm_file, 'base64').toString()) + const helm_version = helm_yaml.version + console.log(`Helm version: ${helm_version}`) + + const update = await github.rest.repos.updateRelease({ + owner: context.payload.repository.owner.login, + repo: context.payload.repository.name, + release_id: draft_release.id, + body: draft_release.body.replace("%HELM_CHART_VERSION%", helm_version), + draft: false + }); + console.log(`Release published: ${update.data.html_url}`) + console.log(`Release notes: ${update.data.body}`) + if: startsWith(github.ref, 'refs/tags/') + - name: Build binaries uses: goreleaser/goreleaser-action@v2 with: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 0bde233788..827477c191 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -91,7 +91,7 @@ jobs: ## Upgrade - For NGINX, use the v${version} image from our [DockerHub](https://hub.docker.com/r/nginx/nginx-ingress/tags?page=1&ordering=last_updated&name=${version}), [GitHub Container](https://github.com/nginxinc/kubernetes-ingress/pkgs/container/kubernetes-ingress) or [Amazon ECR Public Gallery](https://gallery.ecr.aws/nginx/nginx-ingress). - For NGINX Plus, use the v${version} image from the F5 Container registry or the [AWS Marketplace](https://aws.amazon.com/marketplace/search/?CREATOR=741df81b-dfdc-4d36-b8da-945ea66b522c&FULFILLMENT_OPTION_TYPE=CONTAINER&filters=CREATOR%2CFULFILLMENT_OPTION_TYPE) or build your own image using the v${version} source code. - - For Helm, use version HELM_VERSION_REPLACE_ME! of the chart. + - For Helm, use version %HELM_CHART_VERSION% of the chart. ## Resources - Documentation -- https://docs.nginx.com/nginx-ingress-controller/