push image and chart on release on sub project (#49) #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/addon-contrib | |
| 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/addon-contrib | |
| - name: prepare release environment | |
| id: prepare-env | |
| uses: ./go/src/open-cluster-management.io/addon-contrib/.github/actions/prepare-release-env | |
| with: | |
| github_ref: ${{ github.ref }} | |
| outputs: | |
| MAJOR_RELEASE_VERSION: ${{ steps.prepare-env.outputs.MAJOR_RELEASE_VERSION }} | |
| RELEASE_VERSION: ${{ steps.prepare-env.outputs.RELEASE_VERSION }} | |
| TRIMMED_RELEASE_VERSION: ${{ steps.prepare-env.outputs.TRIMMED_RELEASE_VERSION }} | |
| MATRIX: ${{ steps.prepare-env.outputs.MATRIX }} | |
| release: | |
| name: release | |
| runs-on: ubuntu-latest | |
| needs: [ env ] | |
| permissions: | |
| contents: write | |
| strategy: | |
| matrix: ${{ fromJson(needs.env.outputs.MATRIX) }} | |
| steps: | |
| - name: checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| path: go/src/open-cluster-management.io/addon-contrib | |
| - 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 }} ${{ matrix.repository }} ${{ needs.env.outputs.RELEASE_VERSION }} > /home/runner/work/changelog.txt | |
| cat /home/runner/work/changelog.txt | |
| - name: setup helm | |
| uses: azure/setup-helm@v4 | |
| - name: chart package | |
| if: github.event_name != 'pull_request' | |
| run: | | |
| set -e | |
| mkdir -p release | |
| pushd release | |
| yq eval '.dependencies[] | .name + " " + .repository' ../${{ matrix.repository }}/charts/${{ matrix.repository }}/Chart.yaml | while read -r repo_name repo_url; do | |
| if [[ ! "$repo_url" =~ ^(oci://|file://) ]]; then | |
| helm repo add "$repo_name" "$repo_url" | |
| else | |
| echo "Skipping repository $repo_url for $repo_name" | |
| fi | |
| done | |
| if helm repo list | grep -q .; then | |
| helm repo update | |
| else | |
| echo "No helm repositories to update." | |
| fi | |
| helm dependency build ../${{ matrix.repository }}/charts/${{ matrix.repository }} | |
| helm package ../${{ matrix.repository }}/charts/${{ matrix.repository }} \ | |
| --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: | | |
| /home/runner/work/addon-contrib/addon-contrib/go/src/open-cluster-management.io/addon-contrib/release/*.tgz |