|
| 1 | +--- |
| 2 | + |
| 3 | +name: Helm Charts Release |
| 4 | +on: |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + release: |
| 8 | + description: 'Release version' |
| 9 | + required: true |
| 10 | + type: string |
| 11 | + drd_release: |
| 12 | + description: 'DRD Release version' |
| 13 | + required: true |
| 14 | + type: string |
| 15 | + sp_release: |
| 16 | + description: 'Status Provisioner Release version' |
| 17 | + required: true |
| 18 | + type: string |
| 19 | +permissions: |
| 20 | + contents: write |
| 21 | + packages: write |
| 22 | +run-name: ${{ github.repository }} Release ${{ github.event.inputs.release }} |
| 23 | +concurrency: |
| 24 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 25 | + cancel-in-progress: true |
| 26 | +env: |
| 27 | + drd_release: ${{ inputs.drd_release }} |
| 28 | + sp_release: ${{ inputs.sp_release }} |
| 29 | +jobs: |
| 30 | + check-tag: |
| 31 | + runs-on: ubuntu-latest |
| 32 | + steps: |
| 33 | + - name: Check if tag exists |
| 34 | + id: check_tag |
| 35 | + uses: netcracker/qubership-workflow-hub/actions/tag-action@main |
| 36 | + with: |
| 37 | + tag-name: '${{ inputs.release }}' |
| 38 | + ref: ${{ github.ref }} |
| 39 | + create-tag: false |
| 40 | + check-tag: true |
| 41 | + env: |
| 42 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 43 | + |
| 44 | + load-docker-build-components: |
| 45 | + runs-on: ubuntu-latest |
| 46 | + outputs: |
| 47 | + component: ${{ steps.load_component.outputs.components }} |
| 48 | + platforms: ${{ steps.load_component.outputs.platforms }} |
| 49 | + steps: |
| 50 | + - name: Checkout code |
| 51 | + uses: actions/checkout@v4 |
| 52 | + |
| 53 | + - name: Load Docker Configuration |
| 54 | + id: load_component |
| 55 | + run: | |
| 56 | + verify=$(cat "$GITHUB_WORKSPACE/.github/docker-build-config.json" | jq ' |
| 57 | + def verify_structure: |
| 58 | + .components as $components |
| 59 | + | .platforms as $platforms |
| 60 | + | ($components | type == "array") |
| 61 | + and (all($components[]; has("name") and has("file") and has("context"))) |
| 62 | + and ($platforms | type == "string"); |
| 63 | + verify_structure |
| 64 | + | if . then true else false end |
| 65 | + ') |
| 66 | + if [ ${verify} == 'true' ]; then |
| 67 | + echo "✅ $GITHUB_WORKSPACE/.github/docker-build-config.json file is valid" |
| 68 | + components=$(jq -c ".components" "$GITHUB_WORKSPACE/.github/docker-build-config.json") |
| 69 | + platforms=$(jq -c ".platforms" "$GITHUB_WORKSPACE/.github/docker-build-config.json") |
| 70 | + else |
| 71 | + echo "❗ $GITHUB_WORKSPACE/.github/docker-build-config.json file is invalid" |
| 72 | + echo "❗ $GITHUB_WORKSPACE/.github/docker-build-config.json file is invalid" >> $GITHUB_STEP_SUMMARY |
| 73 | + exit 1 |
| 74 | + fi |
| 75 | + echo "components=${components}" >> $GITHUB_OUTPUT |
| 76 | + echo "platforms=${platforms}" >> $GITHUB_OUTPUT |
| 77 | +
|
| 78 | + docker-check-build: |
| 79 | + needs: [load-docker-build-components, check-tag] |
| 80 | + runs-on: ubuntu-latest |
| 81 | + strategy: |
| 82 | + fail-fast: true |
| 83 | + matrix: |
| 84 | + component: ${{ fromJson(needs.load-docker-build-components.outputs.component) }} |
| 85 | + steps: |
| 86 | + - name: Get version for current component |
| 87 | + id: get-version |
| 88 | + run: | |
| 89 | + echo "IMAGE=${{ matrix.component.name }}" >> $GITHUB_ENV |
| 90 | + - name: Docker build |
| 91 | + uses: netcracker/qubership-workflow-hub/actions/docker-action@main |
| 92 | + with: |
| 93 | + ref: ${{ github.ref }} |
| 94 | + download-artifact: false |
| 95 | + dry-run: true |
| 96 | + component: ${{ toJson(matrix.component) }} |
| 97 | + platforms: ${{ needs.load-docker-build-components.outputs.platforms }} |
| 98 | + tags: "${{ env.IMAGE_VERSION }}" |
| 99 | + env: |
| 100 | + GITHUB_TOKEN: ${{ github.token }} |
| 101 | + chart-release-prepare: |
| 102 | + needs: [check-tag, load-docker-build-components, docker-check-build] |
| 103 | + runs-on: ubuntu-latest |
| 104 | + outputs: |
| 105 | + images-versions: ${{ steps.update-versions.outputs.images-versions }} |
| 106 | + steps: |
| 107 | + - name: Checkout code |
| 108 | + uses: actions/checkout@v4 |
| 109 | + with: |
| 110 | + fetch-depth: 0 |
| 111 | + - name: "Update versions in values" |
| 112 | + id: update-versions |
| 113 | + uses: netcracker/qubership-workflow-hub/actions/helm-charts-release@main |
| 114 | + with: |
| 115 | + release-version: ${{ inputs.release }} |
| 116 | + config-file: .github/helm-charts-release-config.yaml |
| 117 | + env: |
| 118 | + ${{ insert }}: ${{ vars }} |
| 119 | + - name: "Debug" |
| 120 | + run: | |
| 121 | + echo "Images versions: ${{ steps.update-versions.outputs.images-versions }}" |
| 122 | + tag: |
| 123 | + needs: [chart-release-prepare] |
| 124 | + runs-on: ubuntu-latest |
| 125 | + steps: |
| 126 | + - name: Create release tag |
| 127 | + uses: netcracker/qubership-workflow-hub/actions/tag-action@main |
| 128 | + with: |
| 129 | + tag-name: "${{ inputs.release }}" |
| 130 | + ref: "release-${{ inputs.release }}" |
| 131 | + create-tag: true |
| 132 | + check-tag: false |
| 133 | + docker-build: |
| 134 | + needs: [tag, chart-release-prepare, load-docker-build-components] |
| 135 | + runs-on: ubuntu-latest |
| 136 | + strategy: |
| 137 | + fail-fast: true |
| 138 | + matrix: |
| 139 | + component: ${{ fromJson(needs.load-docker-build-components.outputs.component) }} |
| 140 | + steps: |
| 141 | + - name: Get version for current component |
| 142 | + id: get-version |
| 143 | + run: | |
| 144 | + echo "IMAGE_VERSION=${{ fromJson(needs.chart-release-prepare.outputs.images-versions)[matrix.component.name] || inputs.release }}" >> $GITHUB_ENV |
| 145 | +
|
| 146 | + - name: Docker build |
| 147 | + uses: netcracker/qubership-workflow-hub/actions/docker-action@main |
| 148 | + with: |
| 149 | + ref: ${{ inputs.release }} |
| 150 | + download-artifact: false |
| 151 | + dry-run: false |
| 152 | + component: ${{ toJson(matrix.component) }} |
| 153 | + platforms: ${{ needs.load-docker-build-components.outputs.platforms }} |
| 154 | + tags: "${{ env.IMAGE_VERSION }},latest" |
| 155 | + env: |
| 156 | + GITHUB_TOKEN: ${{ github.token }} |
| 157 | + |
| 158 | + charts-release: |
| 159 | + needs: [tag, docker-build] |
| 160 | + continue-on-error: true |
| 161 | + runs-on: ubuntu-latest |
| 162 | + steps: |
| 163 | + - name: Checkout code |
| 164 | + uses: actions/checkout@v4 |
| 165 | + with: |
| 166 | + fetch-depth: 0 |
| 167 | + ref: release-${{ inputs.release }} |
| 168 | + |
| 169 | + - name: Configure Git |
| 170 | + run: | |
| 171 | + git config user.name "$GITHUB_ACTOR" |
| 172 | + git config user.email "[email protected]" |
| 173 | +
|
| 174 | + - name: Run chart-releaser |
| 175 | + uses: netcracker/chart-releaser-action@main |
| 176 | + with: |
| 177 | + charts_dir: charts/helm |
| 178 | + release_name_template: "{{ .Version }}" |
| 179 | + env: |
| 180 | + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
| 181 | + |
| 182 | + - name: "Release-drafter" |
| 183 | + uses: netcracker/release-drafter@master |
| 184 | + with: |
| 185 | + config-name: release-drafter-config.yml |
| 186 | + publish: true |
| 187 | + name: ${{ inputs.release }} |
| 188 | + tag: ${{ inputs.release }} |
| 189 | + version: ${{ inputs.release }} |
| 190 | + env: |
| 191 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 192 | + upload-assets: |
| 193 | + needs: [charts-release] |
| 194 | + runs-on: ubuntu-latest |
| 195 | + steps: |
| 196 | + - name: Checkout code |
| 197 | + uses: actions/checkout@v4 |
| 198 | + with: |
| 199 | + ref: ${{ inputs.release }} |
| 200 | + |
| 201 | + - name: Archive and Upload Assets |
| 202 | + uses: netcracker/qubership-workflow-hub/actions/archive-and-upload-assets@main |
| 203 | + with: |
| 204 | + config-path: './.github/assets-config.yml' |
| 205 | + dist-path: './dist' |
| 206 | + upload: true |
| 207 | + ref: ${{ inputs.release }} |
| 208 | + env: |
| 209 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments