From 8ac4af98797624404df9fdc8fab07191018882ee Mon Sep 17 00:00:00 2001 From: jhartmann Date: Fri, 12 Jul 2024 16:05:35 +0200 Subject: [PATCH] chore(release): switch back to pure documentation preparation for release --- .github/workflows/release.yaml | 127 ++++++--------------------------- CONTRIBUTING.md | 20 +++--- 2 files changed, 29 insertions(+), 118 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c46b91960..23c2b91e4 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,4 +1,4 @@ -name: Release IRS +name: Prepare Release documentation on: workflow_dispatch: @@ -25,8 +25,7 @@ env: OPENAPI_SPEC_PATH: 'docs/src/api/irs-api.yaml' HELM_CHART_PATH: 'charts/item-relationship-service' SEMVER_PATTERN: '[0-9]+\.[0-9]+\.[0-9]+' - SEMVER_PATTERN_SED: '[0-9]\+\.[0-9]\+\.[0-9]\+\' - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SEMVER_PATTERN_SED: '[0-9]\+\.[0-9]\+\.[0-9]\+' jobs: release: @@ -47,9 +46,9 @@ jobs: - name: Validate that IRS and Helm Chart versions don't exist yet run: | # IRS version can be checked via git tag since every release has a tag - matched_irs_version=$(git tag | grep -Eo "${{ inputs.irs-version }}" || echo "") + matched_irs_version=$(git tag | grep -Eo "^${{ inputs.irs-version }}" || echo "") # extract from Helm Chart changelog - matched_helm_chart_version=$(grep -Eo "## \[${{ inputs.helm-chart-version }}\]" ${{ env.HELM_CHART_PATH }}/CHANGELOG.md || echo "") + matched_helm_chart_version=$(git tag | grep -Eo "^(irs-helm|item-relationship-service)-${{ inputs.irs-version }}" || echo "") if [[ -n "$matched_irs_version" || -n "$matched_helm_chart_version" ]]; then echo "At least one of the version numbers ${{ inputs.irs-version }} or ${{ inputs.helm-chart-version }} already exists." @@ -119,9 +118,8 @@ jobs: run: sed -i "s|${{ steps.main-changelog-update.outputs.previous-irs-version }}|${{ inputs.irs-version }}|" ${{ env.IRS_APPLICATION_PATH }} - name: Update irs-api.yaml - uses: mikefarah/yq@v4.44.2 - with: - cmd: yq -i eval '.info.version = "${{ inputs.irs-version }}"' ${{ env.OPENAPI_SPEC_PATH }} + run: | + sed -i '0,/version: ${{ env.SEMVER_PATTERN_SED }}/s//version: ${{ inputs.irs-version }}/' ${{ env.OPENAPI_SPEC_PATH }} - name: Update Chart.yaml appVersion uses: mikefarah/yq@v4.44.2 @@ -133,66 +131,6 @@ jobs: with: cmd: yq -i eval '.version = "${{ inputs.helm-chart-version }}"' ${{ env.HELM_CHART_PATH }}/Chart.yaml - - name: Update docs and Helm chart for release - id: cpr - uses: peter-evans/create-pull-request@v6 - with: - commit-message: 'chore(docs): updated docs and Helm chart for IRS release ${{ inputs.irs-version }}' - branch: action/update-for-release-${{ inputs.irs-version }} - delete-branch: true - title: "chore: updated docs and Helm chart for release" - body: This PR prepares the docs and the Helm chart for IRS release ${{ inputs.irs-version }}. - Please check whether everything was updated correctly. Once this PR is merged, the release process will continue automatically. - - - name: Wait for pull request merge - run: | - pull_request_number=${{ steps.cpr.outputs.pull-request-number }} - pull_request_merged="False" - seconds_waited_for_merge=0 - # set duration between api requests - sleep_interval_length=5 # seconds - timeout_in_minutes=15 - - echo "Waiting for merge of PR #$pull_request_number." - - while [[ "$pull_request_merged" == "False" ]] - do - # give some time to merge pull request - sleep "$sleep_interval_length"s - - # retrieve pr status using GH API's pull requests endpoint with GH CLI - pr_status=$(gh pr view $pull_request_number --json state --jq ".state") - - case $pr_status in - - MERGED) - pull_request_merged="True" - echo "PR #$pull_request_number merged, continuing the workflow." - ;; - - OPEN) - seconds_waited_for_merge=$((seconds_waited_for_merge+sleep_interval_length)) - - # abort workflow when having waited for more than allowed time - if [[ $seconds_waited_for_merge -gt $((timeout_in_minutes*60)) ]]; then - echo "Timeout waiting for merge of PR #$pull_request_number, aborting the workflow." - exit 1 - fi - ;; - - CLOSED) - echo "PR #$pull_request_number was closed, aborting the workflow." - exit 1 - ;; - - esac - - done - continue-on-error: false - - - name: Create and push new Git tag for release and pull latest changes - run: git tag ${{ inputs.irs-version }} && git push origin ${{ inputs.irs-version }} && git pull - - name: Extract changelog text # See: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings run: | @@ -203,43 +141,18 @@ jobs: /${{ steps.main-changelog-update.outputs.previous-irs-version }}...${{ inputs.irs-version }} >> $GITHUB_ENV echo "$EOF" >> "$GITHUB_ENV" - - name: Create IRS release - uses: softprops/action-gh-release@v2 + - name: Update docs and Helm chart for release + uses: peter-evans/create-pull-request@v6 with: - body: ${{ env.CHANGELOG }} - tag_name: ${{ inputs.irs-version }} - - release-helm-chart: - name: "Release Helm chart" - needs: - - release - uses: ./.github/workflows/helm-chart-release.yaml - with: - ref-to-check-out: 'refs/tags/${{ inputs.irs-version }}' - - build-irs: - name: "Build IRS" - needs: - - release - uses: ./.github/workflows/irs-build.yml - secrets: inherit - with: - ref-to-check-out: 'refs/tags/${{ inputs.irs-version }}' - - trivy-image-scan: - name: "Scan image in local registry with Trivy" - needs: - - release - uses: ./.github/workflows/trivy-image-scan.yml - secrets: inherit - with: - ref-to-check-out: 'refs/tags/${{ inputs.irs-version }}' - - validate-openapi-definition: - needs: - - release - name: "Validate OpenAPI definition" - uses: ./.github/workflows/swagger-editor-validate.yml - secrets: inherit - with: - ref-to-check-out: 'refs/tags/${{ inputs.irs-version }}' \ No newline at end of file + commit-message: 'chore(docs): updated docs and Helm chart for IRS release ${{ inputs.irs-version }}' + branch: action/update-for-release-${{ inputs.irs-version }} + delete-branch: true + title: "chore: updated docs and Helm chart for release" + body: This PR prepares the docs and the Helm chart for IRS release ${{ inputs.irs-version }}. + Please check whether everything was updated correctly. Once this PR is merged, you can draft a new release + with the following Releasenotes. + + ``` + ${{ env.CHANGELOG }} + + ``` diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 972e37eb0..297234ee6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -212,24 +212,22 @@ https://github.com/google/google-java-format/blob/master/README.md#intellij-jre- 1. Choose a release version using [semantic versioning](https://semver.org/spec/v2.0.0.html) and create a corresponding branch according to the template: `chore/prepare-release-x.x.x`. -2. Add release notes for new version in [CHANGELOG.md](CHANGELOG.md) - and [charts/item-relationship-service/CHANGELOG.md](charts/item-relationship-service/CHANGELOG.md) - (for an example [see here](https://github.com/eclipse-tractusx/item-relationship-service/pull/429)) +2. Make sure the changelog entries [CHANGELOG.md](CHANGELOG.md) + and [charts/item-relationship-service/CHANGELOG.md](charts/item-relationship-service/CHANGELOG.md) are up-to-date - Check if the changelog entries for the release are complete. - Add the corresponding GitHub issue numbers to each entry if missing. 3. Update [COMPATIBILITY_MATRIX.md](COMPATIBILITY_MATRIX.md). -4. Execute the workflow named _"Release IRS"_. The workflow takes three inputs. These are: +4. Execute the workflow named _"Prepare Release documentation"_. The workflow takes three inputs. These are: - IRS release version - type: semantic version string - Helm Chart release version - type: semantic version string - Whether to automatically update the Helm Chart changelog with the change _"- Update IRS version to x.x.x"_. This is a checkbox which is ticked by default. -5. The workflow makes automated changes and creates a pull request from them right away. - Please review the created pull request within 15 minutes. If you fail to do so, or if the - pull request gets closed, the workflow will fail. -6. Once the pull request has been merged, the workflow continues execution. It pushes a tag (which will be - the semantic IRS release version number) and creates the release. Subsequent workflows, such - as the IRS build workflow, are triggered automatically. -7. Notify about the release in IRS Matrix Chat using the following template: +5. The workflow updates the necessary documentation and creates a pull request right away. + Review the changes and merge the PR. +6. Once the pull request has been merged, the helm chart will be release automatically. +7. To create the IRS release, [draft a new release](https://github.com/eclipse-tractusx/item-relationship-service/releases/new). As a tag and title, choose the IRS version provided to the release workflow. (If the release is created from a hotfix branch, make sure to choose this hotfix branch as the target of the tag) +8. Paste the release notes from the PR into the release description. +9. Notify about the release in IRS Matrix Chat using the following template: > **IRS Release x.x.x** >