diff --git a/.github/charts-values-update-config.yaml b/.github/charts-values-update-config.yaml index 4f5d536..1f8c717 100644 --- a/.github/charts-values-update-config.yaml +++ b/.github/charts-values-update-config.yaml @@ -27,5 +27,5 @@ charts: - ghcr.io/netcracker/pgskipper-docker-replication-controller:${release} - ghcr.io/netcracker/pgskipper-docker-pgbackrest-sidecar:${release} - ghcr.io/netcracker/pgskipper-docker-backup-daemon:${release} - # - ghcr.io/netcracker/pgskipper-docker-dbaas-adapter:${release} + - ghcr.io/netcracker/pgskipper-docker-dbaas-adapter:${release} - ghcr.io/netcracker/pgskipper-operator-tests:${release} diff --git a/.github/workflows/helm-charts-release.yaml b/.github/workflows/helm-charts-release.yaml new file mode 100644 index 0000000..818ff25 --- /dev/null +++ b/.github/workflows/helm-charts-release.yaml @@ -0,0 +1,184 @@ +--- +name: Helm Charts Release +on: + workflow_dispatch: + inputs: + release: + description: 'Release version' + required: true + type: string + +permissions: + contents: write + packages: write + +run-name: ${{ github.repository }} Release ${{ github.event.inputs.release }} + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + check-tag: + runs-on: ubuntu-latest + steps: + - name: Check if tag exists + id: check_tag + uses: netcracker/qubership-workflow-hub/actions/tag-action@main + with: + tag-name: '${{ inputs.release }}' + ref: ${{ github.ref }} + create-tag: false + check-tag: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + load-docker-build-components: + runs-on: ubuntu-latest + outputs: + component: ${{ steps.load_component.outputs.components }} + platforms: ${{ steps.load_component.outputs.platforms }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Load Docker Configuration + id: load_component + run: | + verify=$(cat "$GITHUB_WORKSPACE/.github/build-config.cfg" | jq ' + def verify_structure: + .components as $components + | .platforms as $platforms + | ($components | type == "array") + and (all($components[]; has("name") and has("file") and has("context"))) + and ($platforms | type == "string"); + verify_structure + | if . then true else false end + ') + if [ ${verify} == 'true' ]; then + echo "✅ $GITHUB_WORKSPACE/.github/build-config.cfg file is valid" + components=$(jq -c ".components" "$GITHUB_WORKSPACE/.github/build-config.cfg") + platforms=$(jq -c ".platforms" "$GITHUB_WORKSPACE/.github/build-config.cfg") + else + echo "❗ $GITHUB_WORKSPACE/.github/build-config.cfg file is invalid" + echo "❗ $GITHUB_WORKSPACE/.github/build-config.cfg file is invalid" >> $GITHUB_STEP_SUMMARY + exit 1 + fi + echo "components=${components}" >> $GITHUB_OUTPUT + echo "platforms=${platforms}" >> $GITHUB_OUTPUT + + docker-check-build: + needs: [load-docker-build-components, check-tag] + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + component: ${{ fromJson(needs.load-docker-build-components.outputs.component) }} + steps: + - name: Get version for current component + id: get-version + run: | + echo "IMAGE=${{ matrix.component.name }}" >> $GITHUB_ENV + - name: Docker build + uses: netcracker/qubership-workflow-hub/actions/docker-action@main + with: + ref: ${{ github.ref }} + download-artifact: false + dry-run: true + component: ${{ toJson(matrix.component) }} + platforms: ${{ needs.load-docker-build-components.outputs.platforms }} + tags: "${{ env.IMAGE_VERSION }}" + env: + GITHUB_TOKEN: ${{ github.token }} + + chart-release-prepare: + needs: [check-tag, load-docker-build-components, docker-check-build] + runs-on: ubuntu-latest + outputs: + images-versions: ${{ steps.update-versions.outputs.images-versions }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: "Update versions in values" + id: update-versions + uses: netcracker/qubership-workflow-hub/actions/charts-values-update-action@v2.0.1 + with: + release-version: ${{ inputs.release }} + config-file: .github/charts-values-update-config.yaml + env: + ${{ insert }}: ${{ vars }} + - name: "Debug" + run: | + echo "Images versions: ${{ steps.update-versions.outputs.images-versions }}" + + docker-build: + needs: [chart-release-prepare, load-docker-build-components] + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + component: ${{ fromJson(needs.load-docker-build-components.outputs.component) }} + steps: + - name: Get version for current component + id: get-version + run: | + echo "IMAGE_VERSION=${{ fromJson(needs.chart-release-prepare.outputs.images-versions)[matrix.component.name] || inputs.release }}" >> $GITHUB_ENV + + - name: Docker build + uses: netcracker/qubership-workflow-hub/actions/docker-action@main + with: + ref: release-${{ inputs.release }} + download-artifact: false + dry-run: false + component: ${{ toJson(matrix.component) }} + platforms: ${{ needs.load-docker-build-components.outputs.platforms }} + tags: "${{ env.IMAGE_VERSION }},latest" + env: + GITHUB_TOKEN: ${{ github.token }} + + charts-release: + needs: [docker-build] + continue-on-error: false + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: release-${{ inputs.release }} + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Run chart-releaser + uses: netcracker/chart-releaser-action@main + with: + charts_dir: operator/charts/ + release_name_template: "{{ .Version }}" + skip_existing: true + skip_upload: true + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + - name: "Release-drafter" + uses: netcracker/release-drafter@master + with: + config-name: release-drafter-config.yml + publish: true + name: ${{ inputs.release }} + tag: ${{ inputs.release }} + version: ${{ inputs.release }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload Assets + uses: netcracker/qubership-workflow-hub/actions/assets-action@v2.0.11 + with: + tag: ${{ inputs.release }} + item-path: .cr-release-packages/*.tgz + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}