Skip to content

Commit

Permalink
Add chart-upload after release published. (#213)
Browse files Browse the repository at this point in the history
Signed-off-by: xuezhaojun <[email protected]>
  • Loading branch information
xuezhaojun authored Oct 31, 2024
1 parent ca798dc commit 870ab80
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 22 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/chart-upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: ChartUpload

permissions:
contents: read

on:
release:
types: [published]

env:
# Common versions
GO_VERSION: '1.22'
GO_REQUIRED_MIN_VERSION: ''
GITHUB_REF: ${{ github.ref }}
CHART_NAME: 'cluster-proxy'

jobs:
env:
name: prepare release env
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- 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
- name: verify chart version
run: |
cat ./charts/cluster-proxy/Chart.yaml | grep -q 'version: ${{ env.TRIMED_RELEASE_VERSION }}'
outputs:
MAJOR_RELEASE_VERSION: ${{ env.MAJOR_RELEASE_VERSION }}
RELEASE_VERSION: ${{ env.RELEASE_VERSION }}
TRIMED_RELEASE_VERSION: ${{ env.TRIMED_RELEASE_VERSION }}
upload:
name: upload
runs-on: ubuntu-latest
needs: [ env ]
permissions:
contents: write
steps:
- name: submit charts to OCM chart repo
uses: actions/github-script@v7
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.TRIMED_RELEASE_VERSION }}",
"chart-name": "${{ env.CHART_NAME }}",
},
})
console.log(result);
} catch(error) {
console.error(error);
core.setFailed(error);
}
22 changes: 0 additions & 22 deletions .github/workflows/go-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,25 +118,3 @@ jobs:
draft: true
prerelease: false
generate_release_notes: true
- name: submit charts 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.TRIMED_RELEASE_VERSION }}",
"chart-name": "${{ env.CHART_NAME }}",
},
})
console.log(result);
} catch(error) {
console.error(error);
core.setFailed(error);
}

0 comments on commit 870ab80

Please sign in to comment.