Skip to content

🌱 Add chart action into release #20

🌱 Add chart action into release

🌱 Add chart action into release #20

Workflow file for this run

name: GoRelease
permissions:
contents: read
on:
pull_request:
paths:
- .github/workflows/release.yml
push:
tags:
- 'v*.*.*'
env:
GITHUB_REF: ${{ github.ref }}
defaults:
run:
working-directory: go/src/open-cluster-management.io/ocm
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 }}
release:
name: release
runs-on: ubuntu-latest
needs: [ env ]
permissions:
contents: write
steps:
- name: checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
path: go/src/open-cluster-management.io/ocm
- name: Set up Python 3.x
uses: actions/setup-python@v5
with:
# Semantic version range syntax or exact version of a Python version
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install PyGithub
- name: generate changelog
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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
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);
}