|
| 1 | +name: GoRelease |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: read |
| 5 | + |
| 6 | +on: |
| 7 | + pull_request: |
| 8 | + paths: |
| 9 | + - .github/workflows/release.yml |
| 10 | + push: |
| 11 | + tags: |
| 12 | + - '*/v*.*.*' |
| 13 | + |
| 14 | +env: |
| 15 | + GITHUB_REF: ${{ github.ref }} |
| 16 | + |
| 17 | +defaults: |
| 18 | + run: |
| 19 | + working-directory: go/src/open-cluster-management.io/addon-contrib |
| 20 | + |
| 21 | +jobs: |
| 22 | + env: |
| 23 | + name: prepare release env |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - name: checkout code |
| 27 | + uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + fetch-depth: 1 |
| 30 | + path: go/src/open-cluster-management.io/addon-contrib |
| 31 | + |
| 32 | + - name: prepare release environment |
| 33 | + id: prepare-env |
| 34 | + uses: ./go/src/open-cluster-management.io/addon-contrib/.github/actions/prepare-release-env |
| 35 | + with: |
| 36 | + github_ref: ${{ github.ref }} |
| 37 | + outputs: |
| 38 | + MAJOR_RELEASE_VERSION: ${{ steps.prepare-env.outputs.MAJOR_RELEASE_VERSION }} |
| 39 | + RELEASE_VERSION: ${{ steps.prepare-env.outputs.RELEASE_VERSION }} |
| 40 | + TRIMMED_RELEASE_VERSION: ${{ steps.prepare-env.outputs.TRIMMED_RELEASE_VERSION }} |
| 41 | + MATRIX: ${{ steps.prepare-env.outputs.MATRIX }} |
| 42 | + |
| 43 | + release: |
| 44 | + name: release |
| 45 | + runs-on: ubuntu-latest |
| 46 | + needs: [ env ] |
| 47 | + permissions: |
| 48 | + contents: write |
| 49 | + strategy: |
| 50 | + matrix: ${{ fromJson(needs.env.outputs.MATRIX) }} |
| 51 | + steps: |
| 52 | + - name: checkout code |
| 53 | + uses: actions/checkout@v4 |
| 54 | + with: |
| 55 | + fetch-depth: 1 |
| 56 | + path: go/src/open-cluster-management.io/addon-contrib |
| 57 | + |
| 58 | + - name: Set up Python 3.x |
| 59 | + uses: actions/setup-python@v5 |
| 60 | + with: |
| 61 | + # Semantic version range syntax or exact version of a Python version |
| 62 | + python-version: '3.x' |
| 63 | + |
| 64 | + - name: Install dependencies |
| 65 | + run: | |
| 66 | + python -m pip install --upgrade pip |
| 67 | + pip install PyGithub |
| 68 | +
|
| 69 | + - name: generate changelog |
| 70 | + run: | |
| 71 | + python hack/changelog.py ${{ secrets.GITHUB_TOKEN }} ${{ matrix.repository }} ${{ needs.env.outputs.RELEASE_VERSION }} > /home/runner/work/changelog.txt |
| 72 | + cat /home/runner/work/changelog.txt |
| 73 | +
|
| 74 | + - name: setup helm |
| 75 | + uses: azure/setup-helm@v4 |
| 76 | + |
| 77 | + - name: chart package |
| 78 | + if: github.event_name != 'pull_request' |
| 79 | + run: | |
| 80 | + set -e |
| 81 | + mkdir -p release |
| 82 | + pushd release |
| 83 | + yq eval '.dependencies[] | .name + " " + .repository' ../${{ matrix.repository }}/charts/${{ matrix.repository }}/Chart.yaml | while read -r repo_name repo_url; do |
| 84 | + if [[ ! "$repo_url" =~ ^(oci://|file://) ]]; then |
| 85 | + helm repo add "$repo_name" "$repo_url" |
| 86 | + else |
| 87 | + echo "Skipping repository $repo_url for $repo_name" |
| 88 | + fi |
| 89 | + done |
| 90 | + if helm repo list | grep -q .; then |
| 91 | + helm repo update |
| 92 | + else |
| 93 | + echo "No helm repositories to update." |
| 94 | + fi |
| 95 | + helm dependency build ../${{ matrix.repository }}/charts/${{ matrix.repository }} |
| 96 | + helm package ../${{ matrix.repository }}/charts/${{ matrix.repository }} \ |
| 97 | + --version ${{ needs.env.outputs.TRIMMED_RELEASE_VERSION }} |
| 98 | + popd |
| 99 | +
|
| 100 | + - name: publish release |
| 101 | + if: github.event_name != 'pull_request' |
| 102 | + uses: softprops/action-gh-release@v2 |
| 103 | + env: |
| 104 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 105 | + with: |
| 106 | + body_path: /home/runner/work/changelog.txt |
| 107 | + draft: true |
| 108 | + generate_release_notes: true |
| 109 | + files: | |
| 110 | + /home/runner/work/addon-contrib/addon-contrib/go/src/open-cluster-management.io/addon-contrib/release/*.tgz |
0 commit comments