Skip to content

Commit

Permalink
🌱 Add chart action into release (#578)
Browse files Browse the repository at this point in the history
* Add chart action into release

Signed-off-by: Jian Qiu <[email protected]>

* Update chart upload action

Signed-off-by: Jian Qiu <[email protected]>

---------

Signed-off-by: Jian Qiu <[email protected]>
  • Loading branch information
qiujian16 authored Sep 3, 2024
1 parent a8a5add commit 1fc820a
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 1 deletion.
83 changes: 83 additions & 0 deletions .github/workflows/chart-upload.yml
Original file line number Diff line number Diff line change
@@ -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);
}
12 changes: 12 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ 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
if: github.event_name != 'pull_request'
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
Expand All @@ -71,3 +81,5 @@ jobs:
body_path: /home/runner/work/changelog.txt
draft: true
generate_release_notes: true
files: |
release/*.tgz
2 changes: 1 addition & 1 deletion .github/workflows/releaseimage.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: GoRelease
name: ImageRelease

on:
push:
Expand Down

0 comments on commit 1fc820a

Please sign in to comment.