From 95d117b8a871dd2bc6e4449156a91e5c111cb878 Mon Sep 17 00:00:00 2001 From: Jian Qiu Date: Mon, 29 Jul 2024 16:24:55 +0800 Subject: [PATCH 1/2] Add chart action into release Signed-off-by: Jian Qiu --- .github/workflows/release.yml | 55 ++++++++++++++++++++++++++++++ .github/workflows/releaseimage.yml | 2 +- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 62a225e95..09e865571 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -62,6 +62,15 @@ jobs: run: | python hack/changelog.py ${{ secrets.GITHUB_TOKEN }} ${{ needs.env.outputs.RELEASE_VERSION }} > /home/runner/work/changelog.txt cat /home/runner/work/changelog.txt + - name: setup helm + uses: azure/setup-helm@v1 + - name: chart package + run: | + mkdir -p release + pushd release + helm package ../deploy/cluster-manager/chart/cluster-manager --app-version ${{ needs.env.outputs.TRIMMED_RELEASE_VERSION }} + helm package ../deploy/klusterlet/chart/klusterlet --app-version ${{ needs.env.outputs.TRIMMED_RELEASE_VERSION }} + popd - name: publish release if: github.event_name != 'pull_request' uses: softprops/action-gh-release@v2 @@ -71,3 +80,49 @@ jobs: body_path: /home/runner/work/changelog.txt draft: true generate_release_notes: true + files: | + release/*.tgz + - name: submit cluster-manager chart to OCM chart repo + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.OCM_BOT_PAT }} + script: | + try { + const result = await github.rest.actions.createWorkflowDispatch({ + owner: 'open-cluster-management-io', + repo: 'helm-charts', + workflow_id: 'download-chart.yml', + ref: 'main', + inputs: { + repo: "${{ github.repository }}", + version: "${{ needs.env.outputs.TRIMMED_RELEASE_VERSION }}", + "chart-name": "cluster-manager", + }, + }) + console.log(result); + } catch(error) { + console.error(error); + core.setFailed(error); + } + - name: submit klusterlet chart to OCM chart repo + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.OCM_BOT_PAT }} + script: | + try { + const result = await github.rest.actions.createWorkflowDispatch({ + owner: 'open-cluster-management-io', + repo: 'helm-charts', + workflow_id: 'download-chart.yml', + ref: 'main', + inputs: { + repo: "${{ github.repository }}", + version: "${{ needs.env.outputs.TRIMMED_RELEASE_VERSION }}", + "chart-name": "klusterlet", + }, + }) + console.log(result); + } catch(error) { + console.error(error); + core.setFailed(error); + } diff --git a/.github/workflows/releaseimage.yml b/.github/workflows/releaseimage.yml index 87aa97531..c7b4d98ad 100644 --- a/.github/workflows/releaseimage.yml +++ b/.github/workflows/releaseimage.yml @@ -1,4 +1,4 @@ -name: GoRelease +name: ImageRelease on: push: From f8ceee3674a3082c5ec6d4b4dba3753e05246536 Mon Sep 17 00:00:00 2001 From: Jian Qiu Date: Mon, 2 Sep 2024 11:36:35 +0800 Subject: [PATCH 2/2] Update chart upload action Signed-off-by: Jian Qiu --- .github/workflows/chart-upload.yml | 83 ++++++++++++++++++++++++++++++ .github/workflows/release.yml | 45 +--------------- 2 files changed, 84 insertions(+), 44 deletions(-) create mode 100644 .github/workflows/chart-upload.yml diff --git a/.github/workflows/chart-upload.yml b/.github/workflows/chart-upload.yml new file mode 100644 index 000000000..3f2e6ac82 --- /dev/null +++ b/.github/workflows/chart-upload.yml @@ -0,0 +1,83 @@ +name: ChartUpload + +permissions: + contents: read + +on: + release: + types: [published] + + +jobs: + env: + name: prepare release env + runs-on: ubuntu-latest + steps: + - name: checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 1 + path: go/src/open-cluster-management.io/ocm + - name: get release version + run: | + echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + - name: get major release version + run: | + echo "MAJOR_RELEASE_VERSION=${RELEASE_VERSION%.*}" >> $GITHUB_ENV + echo "TRIMED_RELEASE_VERSION=${RELEASE_VERSION#v}" >> $GITHUB_ENV + outputs: + MAJOR_RELEASE_VERSION: ${{ env.MAJOR_RELEASE_VERSION }} + RELEASE_VERSION: ${{ env.RELEASE_VERSION }} + upload: + name: upload + runs-on: ubuntu-latest + needs: [ env ] + permissions: + contents: write + steps: + - name: submit cluster-manager chart to OCM chart repo + if: github.event_name != 'pull_request' + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.OCM_BOT_PAT }} + script: | + try { + const result = await github.rest.actions.createWorkflowDispatch({ + owner: 'open-cluster-management-io', + repo: 'helm-charts', + workflow_id: 'download-chart.yml', + ref: 'main', + inputs: { + repo: "${{ github.repository }}", + version: "${{ needs.env.outputs.TRIMMED_RELEASE_VERSION }}", + "chart-name": "cluster-manager", + }, + }) + console.log(result); + } catch(error) { + console.error(error); + core.setFailed(error); + } + - name: submit klusterlet chart to OCM chart repo + if: github.event_name != 'pull_request' + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.OCM_BOT_PAT }} + script: | + try { + const result = await github.rest.actions.createWorkflowDispatch({ + owner: 'open-cluster-management-io', + repo: 'helm-charts', + workflow_id: 'download-chart.yml', + ref: 'main', + inputs: { + repo: "${{ github.repository }}", + version: "${{ needs.env.outputs.TRIMMED_RELEASE_VERSION }}", + "chart-name": "klusterlet", + }, + }) + console.log(result); + } catch(error) { + console.error(error); + core.setFailed(error); + } diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 09e865571..12322a067 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -65,6 +65,7 @@ jobs: - name: setup helm uses: azure/setup-helm@v1 - name: chart package + if: github.event_name != 'pull_request' run: | mkdir -p release pushd release @@ -82,47 +83,3 @@ jobs: generate_release_notes: true files: | release/*.tgz - - name: submit cluster-manager chart to OCM chart repo - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.OCM_BOT_PAT }} - script: | - try { - const result = await github.rest.actions.createWorkflowDispatch({ - owner: 'open-cluster-management-io', - repo: 'helm-charts', - workflow_id: 'download-chart.yml', - ref: 'main', - inputs: { - repo: "${{ github.repository }}", - version: "${{ needs.env.outputs.TRIMMED_RELEASE_VERSION }}", - "chart-name": "cluster-manager", - }, - }) - console.log(result); - } catch(error) { - console.error(error); - core.setFailed(error); - } - - name: submit klusterlet chart to OCM chart repo - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.OCM_BOT_PAT }} - script: | - try { - const result = await github.rest.actions.createWorkflowDispatch({ - owner: 'open-cluster-management-io', - repo: 'helm-charts', - workflow_id: 'download-chart.yml', - ref: 'main', - inputs: { - repo: "${{ github.repository }}", - version: "${{ needs.env.outputs.TRIMMED_RELEASE_VERSION }}", - "chart-name": "klusterlet", - }, - }) - console.log(result); - } catch(error) { - console.error(error); - core.setFailed(error); - }