diff --git a/.github/actions/publish-tag-and-release/action.yml b/.github/actions/publish-tag-and-release/action.yml new file mode 100644 index 000000000..7499ccb27 --- /dev/null +++ b/.github/actions/publish-tag-and-release/action.yml @@ -0,0 +1,92 @@ +################################################################################# +# Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# Copyright (c) 2024 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License, Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# SPDX-License-Identifier: Apache-2.0 +################################################################################# + + +--- +name: "Publish Github release and tag" +description: "Publish Github release and tag" +inputs: + version: + required: true + description: "The version to be used in the tag and release publication" + token: + required: true + description: "Github token" + is_latest: + required: true + description: "Boolean that defines if a release is latest or not" + +runs: + using: "composite" + steps: + - uses: actions/checkout@v4 + - name: Prepare Git Config + shell: bash + run: | + # Prepare git env + git config user.name "eclipse-tractusx-bot" + git config user.email "tractusx-bot@eclipse.org" + - name: Create Release Tag + id: create_release_tag + shell: bash + run: | + # informative + git branch -a + git tag + + # Create & push tag + git tag ${{ inputs.version }} + git push origin ${{ inputs.version }} + - name: Create GitHub Release + uses: ncipollo/release-action@v1 + with: + generateReleaseNotes: true + tag: ${{ inputs.version }} + token: ${{ inputs.token }} + makeLatest: ${{ inputs.is_latest }} + removeArtifacts: true + - uses: ./.github/actions/setup-java + - name: Set new snapshot version + if: ${{ inputs.is_latest }} + shell: bash + run: | + # Extract release version + IFS=.- read -r RELEASE_VERSION_MAJOR RELEASE_VERSION_MINOR RELEASE_VERSION_PATCH SNAPSHOT<<<"${{ inputs.version}}" + INC=0 + # Compute new snapshot version, do not increment snapshot on non-final releases, e.g. -rc1 + if [ -z $SNAPSHOT ]; then + # snapshot + echo "${{ inputs.version }} is a final release version, increase patch for next snapshot" + INC=1 + else + echo "${{ inputs.version }} is not a final release version (contains \"$SNAPSHOT\"), will not increase patch" + fi + + VERSION="$RELEASE_VERSION_MAJOR.$((RELEASE_VERSION_MINOR+$INC)).0-SNAPSHOT" + SNAPSHOT_VERSION=$VERSION + + # Persist the "version" in the gradle.properties + sed -i "s/version=.*/version=$SNAPSHOT_VERSION/g" gradle.properties + + # Commit and push to origin main + git add gradle.properties + git commit --message "Introduce new snapshot version $SNAPSHOT_VERSION" + + git push diff --git a/.github/workflows/draft-new-release.yaml b/.github/workflows/draft-release.yaml similarity index 57% rename from .github/workflows/draft-new-release.yaml rename to .github/workflows/draft-release.yaml index 0eb2da28b..3cdf9e1d0 100644 --- a/.github/workflows/draft-new-release.yaml +++ b/.github/workflows/draft-release.yaml @@ -1,4 +1,5 @@ ################################################################################# +# Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) # Copyright (c) 2021,2023 Contributors to the Eclipse Foundation # # See the NOTICE file(s) distributed with this work for additional @@ -19,19 +20,57 @@ --- -name: "Draft new release" +name: "Draft Release" +run-name: "Draft Release ${{ inputs.version }} from ${{ github.ref_name }}" on: workflow_dispatch: inputs: version: - description: 'The version you want to release.' + description: 'The version you want to release. Ref should be either main for latest releases or a tag for bugfixes. ' required: true jobs: + validate-and-prepare: + name: "Validate that tag does not already exist and prepare branch" + runs-on: ubuntu-latest + if: ${{ github.ref_name == 'main' || startsWith(github.ref, 'refs/tags/') }} + outputs: + branch_name: ${{ steps.resolve_branch.outputs.branch_name }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - id: check-tag + name: "Check if tag exists" + run: |- + + tag=$(git tag -l ${{ inputs.version }}) + + if [ ! -z $tag ]; + then + echo "Tag already exists! Please choose another tag." + exit 1 + fi + - id: resolve_branch + name: "Resolve branch prefix (release or bugfix)" + run: | + + if [[ ${{ github.ref_name }} == "main"]]; + then + echo "branch_name=release/${{ inputs.version }}" >> "$GITHUB_OUTPUT" + elif [[ ${{ github.ref }} == refs/tags/* ]] + then + echo "branch_name=bugfix/${{ inputs.version }}" >> "$GITHUB_OUTPUT" + else + echo "Ref branch does not match required criteria. Should either be "main" or a tag." + exit 1 + fi + draft-new-release: name: "Draft a new release" runs-on: ubuntu-latest + needs: validate-and-prepare permissions: contents: write packages: write @@ -39,8 +78,8 @@ jobs: pull-requests: write steps: - uses: actions/checkout@v4 - - name: Create release branch - run: git checkout -b release/${{ github.event.inputs.version }} + - name: Create Release or Bugfix branch + run: git checkout -b ${{ needs.validate-and-prepare.outputs.branch_name }} - name: Initialize mandatory git config run: | git config user.name "eclipse-tractusx-bot" @@ -49,9 +88,9 @@ jobs: - name: Bump version in gradle.properties run: |- # replace the project's (default) version, could be overwritten later with the -Pversion=... flag - sed -i 's/version=.*/version=${{ github.event.inputs.version }}/g' gradle.properties + sed -i 's/version=.*/version=${{ inputs.version }}/g' gradle.properties # replace the openapi version with the upcoming one - sed -i 's#tractusx-edc/.*/swagger.yaml#tractusx-edc/${{ github.event.inputs.version }}/swagger.yaml#g' .tractusx + sed -i 's#tractusx-edc/.*/swagger.yaml#tractusx-edc/${{ inputs.version }}/swagger.yaml#g' .tractusx env: GITHUB_PACKAGE_USERNAME: ${{ github.actor }} GITHUB_PACKAGE_PASSWORD: ${{ secrets.GITHUB_TOKEN }} @@ -59,7 +98,7 @@ jobs: uses: mikefarah/yq@v4.44.3 with: cmd: |- - find charts -name Chart.yaml -maxdepth 3 | xargs -n1 yq -i '.appVersion = "${{ github.event.inputs.version }}" | .version = "${{ github.event.inputs.version }}"' + find charts -name Chart.yaml -maxdepth 3 | xargs -n1 yq -i '.appVersion = "${{ inputs.version }}" | .version = "${{ inputs.version }}"' - name: Update Chart READMEs uses: addnab/docker-run-action@v3 with: @@ -71,22 +110,23 @@ jobs: id: make-commit run: | git add gradle.properties $(find charts -name Chart.yaml) $(find charts -name README.md) - git commit --message "Prepare release ${{ github.event.inputs.version }}" + git commit --message "Prepare release ${{ inputs.version }}" echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - name: Push new branch - run: git push origin release/${{ github.event.inputs.version }} + run: git push origin ${{ needs.validate-and-prepare.outputs.branch_name }} - name: Create pull request + if: ${{ github.ref_name == 'main' }} uses: thomaseizinger/create-pull-request@1.4.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - head: release/${{ github.event.inputs.version }} - base: releases - title: Release version ${{ github.event.inputs.version }} + head: ${{ needs.validate-and-prepare.outputs.branch_name }} + base: main + title: Release version ${{ inputs.version }} reviewers: ${{ github.actor }} body: |- - This PR was created in response to a manual trigger of the [release workflow](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}). + This PR was created in response to a manual trigger of the [draft release workflow](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}). Versions have been bumped in [commit ${{ steps.make-commit.outputs.commit }}](${{ steps.make-commit.outputs.commit }}). Merging this PR will create a GitHub release and upload any assets that are created as part of the release build. diff --git a/.github/workflows/manual-release-bugfix.yml b/.github/workflows/manual-release-bugfix.yml new file mode 100644 index 000000000..a96199587 --- /dev/null +++ b/.github/workflows/manual-release-bugfix.yml @@ -0,0 +1,38 @@ +################################################################################# +# Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# Copyright (c) 2021,2023 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License, Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# SPDX-License-Identifier: Apache-2.0 +################################################################################# + + +--- +name: "Bugfix Release" +run-name: "Release bugfix from ${{ github.ref_name }}" + +on: + workflow_dispatch: + +jobs: + # Gate: Skip if base is not bugfix branch + check-head: + name: "Check if head is bugfix and delegate to release workflow" + if: startsWith(github.ref_name, 'bugfix/') + uses: ./.github/workflows/release.yml + permissions: + contents: write + pages: write + secrets: inherit diff --git a/.github/workflows/publish-bugfix-release.yml b/.github/workflows/publish-bugfix-release.yml deleted file mode 100644 index ce02da52b..000000000 --- a/.github/workflows/publish-bugfix-release.yml +++ /dev/null @@ -1,211 +0,0 @@ -################################################################################# -# Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License, Version 2.0 which is available at -# https://www.apache.org/licenses/LICENSE-2.0. -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# SPDX-License-Identifier: Apache-2.0 -################################################################################# - - ---- -name: "Publish bugfix release" - -# Temporary workflow to enable the release of bugfix versions. -# Should be reworked as this file contains duplicate code from draft-new-release and publish-new-release -# This workflow, as is, should be executed after the bugfix branch is created and all needed PRs are merged - -on: - workflow_dispatch: - inputs: - version: - description: 'The bugfix version you want to release.' - required: true - -jobs: - # Gate: Check release version presence - validate-release: - name: Validate if bugfix version can be released - runs-on: ubuntu-latest - if: startsWith(github.ref_name, 'bugfix/') - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - id: check-tag - name: Check if tag exists - run: |- - - tag=$(git tag -l ${{ inputs.version }}) - - if [ ! -z $tag ]; - then - echo "Tag already exists! Please choose another tag." - exit 1 - fi - - prepare-bugfix-release: - name: "Prepare bugfix release" - runs-on: ubuntu-latest - needs: [validate-release] - permissions: - contents: write - steps: - - uses: actions/checkout@v4 - - name: Initialize mandatory git config - run: | - git config user.name "eclipse-tractusx-bot" - git config user.email "tractusx-bot@eclipse.org" - - uses: ./.github/actions/setup-java - - name: Bump version in gradle.properties - run: |- - # replace the project's (default) version, could be overwritten later with the -Pversion=... flag - sed -i 's/version=.*/version=${{ inputs.version }}/g' gradle.properties - # replace the openapi version with the upcoming one - sed -i 's#tractusx-edc/.*/swagger.yaml#tractusx-edc/${{ github.event.inputs.version }}/swagger.yaml#g' .tractusx - env: - GITHUB_PACKAGE_USERNAME: ${{ github.actor }} - GITHUB_PACKAGE_PASSWORD: ${{ secrets.GITHUB_TOKEN }} - - name: Bump version in /charts - uses: mikefarah/yq@v4.44.3 - with: - cmd: |- - find charts -name Chart.yaml -maxdepth 3 | xargs -n1 yq -i '.appVersion = "${{ inputs.version }}" | .version = "${{ inputs.version }}"' - - name: Update Chart READMEs - uses: addnab/docker-run-action@v3 - with: - image: jnorwood/helm-docs:v1.10.0 - options: -v ${{ github.workspace }}/charts:/helm-docs - run: | - helm-docs --log-level debug - - name: Commit manifest files - id: make-commit - run: | - git add gradle.properties $(find charts -name Chart.yaml) $(find charts -name README.md) - git commit --message "Prepare release ${{ inputs.version }}" - - - # Release: Maven Artifacts - maven-release: - name: Publish extension's release version to maven repository - needs: [ prepare-bugfix-release, validate-release ] - permissions: - contents: read - uses: ./.github/workflows/trigger-maven-publish.yaml - secrets: inherit - with: - version: ${{ inputs.version }} - - docker-release: - name: Publish Docker images - needs: [ prepare-bugfix-release, validate-release ] - permissions: - contents: write - - uses: ./.github/workflows/trigger-docker-publish.yaml - secrets: inherit - with: - docker_tag: ${{ inputs.version }} - - # Release: Helm Charts - helm-release: - name: Publish new helm release - needs: [ prepare-bugfix-release, validate-release ] - runs-on: ubuntu-latest - permissions: - contents: write - pages: write - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Install Helm - uses: azure/setup-helm@v4 - with: - version: v3.8.1 - - name: Package helm, update index.yaml and push to gh-pages - run: | - # Prepare git env - git config user.name "eclipse-tractusx-bot" - git config user.email "tractusx-bot@eclipse.org" - - # Package all charts - find charts -name Chart.yaml -not -path "./edc-tests/*" | xargs -n1 dirname | xargs -n1 helm package -u -d helm-charts - - git checkout gh-pages || git checkout -b gh-pages - git pull --rebase origin gh-pages - - # Generate helm repo index.yaml - helm repo index . --merge index.yaml --url https://${GITHUB_REPOSITORY_OWNER}.github.io/${GITHUB_REPOSITORY#*/}/ - - # Commit and push to gh-pages - git add index.yaml helm-charts - git commit -s -m "Release ${{ inputs.version }}" - - git push origin gh-pages - - # Release: GitHub tag & release; - github-release: - name: Publish new github release - needs: [ prepare-bugfix-release, validate-release, maven-release, docker-release, helm-release ] - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - uses: actions/checkout@v4 - with: - # 0 to fetch the full history due to upcoming merge of releases into main branch - fetch-depth: 0 - - name: Create Release Tag - id: create_release_tag - run: | - # Prepare git env - git config user.name "eclipse-tractusx-bot" - git config user.email "tractusx-bot@eclipse.org" - - # informative - git branch -a - git tag - - # Create & push tag - git tag --force ${{ inputs.version }} - git push --force origin ${{ inputs.version }} - - name: Create GitHub Release - uses: ncipollo/release-action@v1 - with: - generateReleaseNotes: true - tag: ${{ inputs.version }} - token: ${{ secrets.GITHUB_TOKEN }} - makeLatest: false - removeArtifacts: true - - publish-to-swaggerhub: - name: "Publish OpenAPI spec to Swaggerhub" - permissions: - contents: read - needs: [ prepare-bugfix-release, validate-release ] - uses: ./.github/workflows/publish-swaggerhub.yaml - with: - downstream-version: ${{ inputs.version }} - secrets: inherit - - publish-openapi-to-gh-pages: - name: "Publish OpenAPI UI spec GitHub Pages" - permissions: - contents: write - needs: [ prepare-bugfix-release, validate-release ] - uses: ./.github/workflows/publish-openapi-ui.yml - secrets: inherit - with: - version: ${{ inputs.version }} \ No newline at end of file diff --git a/.github/workflows/publish-new-release.yml b/.github/workflows/publish-new-release.yml deleted file mode 100644 index b7318042e..000000000 --- a/.github/workflows/publish-new-release.yml +++ /dev/null @@ -1,220 +0,0 @@ -################################################################################# -# Copyright (c) 2021,2023 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License, Version 2.0 which is available at -# https://www.apache.org/licenses/LICENSE-2.0. -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# SPDX-License-Identifier: Apache-2.0 -################################################################################# - - ---- -name: "Publish new release" - -on: - pull_request: - branches: - - releases - - support/* - types: - - closed - -jobs: - # Gate: Check release version presence - release-version: - name: Determine release version - runs-on: ubuntu-latest - outputs: - RELEASE_VERSION: ${{ steps.release-version.outputs.RELEASE_VERSION }} - steps: - - name: Extract version from branch name (for release branches) - if: startsWith(github.event.pull_request.head.ref, 'release/') - run: | - BRANCH_NAME="${{ github.event.pull_request.head.ref }}" - VERSION=${BRANCH_NAME#release/} - - echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV - - name: Extract version from branch name (for hotfix branches) - if: startsWith(github.event.pull_request.head.ref, 'hotfix/') - run: | - BRANCH_NAME="${{ github.event.pull_request.head.ref }}" - VERSION=${BRANCH_NAME#hotfix/} - - echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV - - name: Output release version - id: release-version - run: | - echo "RELEASE_VERSION=${{ env.RELEASE_VERSION }}" >> $GITHUB_OUTPUT - - # Release: Maven Artifacts - maven-release: - name: Publish extension's release version to maven repository - needs: [ release-version ] - permissions: - contents: read - packages: write - if: github.event.pull_request.merged == true && needs.release-version.outputs.RELEASE_VERSION - uses: ./.github/workflows/trigger-maven-publish.yaml - secrets: inherit - with: - version: ${{ needs.release-version.outputs.RELEASE_VERSION }} - - docker-release: - name: Publish Docker images - needs: [ release-version ] - permissions: - contents: write - if: github.event.pull_request.merged == true && needs.release-version.outputs.RELEASE_VERSION - - uses: ./.github/workflows/trigger-docker-publish.yaml - secrets: inherit - with: - docker_tag: ${{ needs.release-version.outputs.RELEASE_VERSION }} - - # Release: Helm Charts - helm-release: - name: Publish new helm release - needs: [ release-version ] - runs-on: ubuntu-latest - permissions: - contents: write - pages: write - - if: github.event.pull_request.merged == true && needs.release-version.outputs.RELEASE_VERSION - steps: - - name: Export RELEASE_VERSION env - run: | - echo "RELEASE_VERSION=${{ needs.release-version.outputs.RELEASE_VERSION }}" >> $GITHUB_ENV - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Install Helm - uses: azure/setup-helm@v4 - with: - version: v3.8.1 - - name: Package helm, update index.yaml and push to gh-pages - run: | - # Prepare git env - git config user.name "eclipse-tractusx-bot" - git config user.email "tractusx-bot@eclipse.org" - - # Package all charts - find charts -name Chart.yaml -not -path "./edc-tests/*" | xargs -n1 dirname | xargs -n1 helm package -u -d helm-charts - - git checkout gh-pages || git checkout -b gh-pages - git pull --rebase origin gh-pages - - # Generate helm repo index.yaml - helm repo index . --merge index.yaml --url https://${GITHUB_REPOSITORY_OWNER}.github.io/${GITHUB_REPOSITORY#*/}/ - - # Commit and push to gh-pages - git add index.yaml helm-charts - git commit -s -m "Release ${{ env.RELEASE_VERSION }}" - - git push origin gh-pages - - # Release: GitHub tag & release; Merges back releases into main; Starts a new development cycle; - github-release: - name: Publish new github release - needs: [ release-version, maven-release, docker-release, helm-release ] - runs-on: ubuntu-latest - permissions: - contents: write - packages: write - pages: write - pull-requests: write - if: github.event.pull_request.merged == true && needs.release-version.outputs.RELEASE_VERSION - steps: - - name: Export RELEASE_VERSION env - run: | - echo "RELEASE_VERSION=${{ needs.release-version.outputs.RELEASE_VERSION }}" >> $GITHUB_ENV - - uses: actions/checkout@v4 - with: - # 0 to fetch the full history due to upcoming merge of releases into main branch - fetch-depth: 0 - - name: Create Release Tag - id: create_release_tag - run: | - # Prepare git env - git config user.name "eclipse-tractusx-bot" - git config user.email "tractusx-bot@eclipse.org" - - # informative - git branch -a - git tag - - # Create & push tag - git tag --force ${{ env.RELEASE_VERSION }} - git push --force origin ${{ env.RELEASE_VERSION }} - - name: Create GitHub Release - uses: ncipollo/release-action@v1 - with: - generateReleaseNotes: true - tag: ${{ env.RELEASE_VERSION }} - token: ${{ secrets.GITHUB_TOKEN }} - makeLatest: true - removeArtifacts: true - - uses: ./.github/actions/setup-java - - name: Merge releases back into main and set new snapshot version - if: github.event.pull_request.base.ref == 'releases' - run: | - # Prepare git env - git config user.name "eclipse-tractusx-bot" - git config user.email "tractusx-bot@eclipse.org" - - # Merge releases into main - git checkout main && git merge -X theirs releases --no-commit --no-ff - - # Extract release version - IFS=.- read -r RELEASE_VERSION_MAJOR RELEASE_VERSION_MINOR RELEASE_VERSION_PATCH SNAPSHOT<<<"${{ env.RELEASE_VERSION }}" - INC=0 - # Compute new snapshot version, do not increment snapshot on non-final releases, e.g. -rc1 - if [ -z $SNAPSHOT ]; then - # snapshot - echo "${{ env.RELEASE_VERSION }} is a final release version, increase patch for next snapshot" - INC=1 - else - echo "${{ env.RELEASE_VERSION }} is not a final release version (contains \"$SNAPSHOT\"), will not increase patch" - fi - - VERSION="$RELEASE_VERSION_MAJOR.$RELEASE_VERSION_MINOR.$((RELEASE_VERSION_PATCH+$INC))-SNAPSHOT" - SNAPSHOT_VERSION=$VERSION - - # Persist the "version" in the gradle.properties - sed -i "s/version=.*/version=$SNAPSHOT_VERSION/g" gradle.properties - - # Commit and push to origin main - git add gradle.properties - git commit --message "Introduce new snapshot version $SNAPSHOT_VERSION" - - git push origin main - - publish-to-swaggerhub: - name: "Publish OpenAPI spec to Swaggerhub" - permissions: - contents: read - needs: [ release-version ] - uses: ./.github/workflows/publish-swaggerhub.yaml - with: - downstream-version: ${{ needs.release-version.outputs.RELEASE_VERSION }} - secrets: inherit - - publish-openapi-to-gh-pages: - name: "Publish OpenAPI UI spec GitHub Pages" - permissions: - contents: write - needs: [ release-version ] - uses: ./.github/workflows/publish-openapi-ui.yml - secrets: inherit - with: - version: ${{ needs.release-version.outputs.RELEASE_VERSION }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..37fff07c7 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,147 @@ +################################################################################# +# Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# Copyright (c) 2021,2023 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License, Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# SPDX-License-Identifier: Apache-2.0 +################################################################################# + + +--- +name: "Release" + +on: + pull_request: + branches: + - main + types: + - closed + + workflow_call: + + +jobs: + # Gate + validation: + name: "Check if repository is not fork AND head is release OR base is bugfix" + runs-on: ubuntu-latest + if: ${{ github.repository == 'eclipse-tractusx/tractusx-edc' && (startsWith(github.ref_name, 'bugfix/') || startsWith(github.event.pull_request.head.ref, 'release/')) }} + outputs: + RELEASE_VERSION: ${{ steps.release-version.outputs.RELEASE_VERSION }} + steps: + - uses: actions/checkout@v4 + - name: Output release version + id: release-version + run: | + VERSION=$(grep "version" gradle.properties | awk -F= '{print $2}') + echo "RELEASE_VERSION=$VERSION" >> $GITHUB_OUTPUT + + # Release: Maven Artifacts + maven-release: + name: Publish extension's release version to maven repository + needs: [ validation ] + permissions: + contents: read + if: needs.validation.outputs.RELEASE_VERSION + uses: ./.github/workflows/trigger-maven-publish.yaml + secrets: inherit + with: + version: ${{ needs.validation.outputs.RELEASE_VERSION }} + + # Release: docker images + docker-release: + name: Publish Docker images + needs: [ validation ] + if: needs.validation.outputs.RELEASE_VERSION + uses: ./.github/workflows/trigger-docker-publish.yaml + secrets: inherit + with: + docker_tag: ${{ needs.validation.outputs.RELEASE_VERSION }} + + # Release: Helm charts + helm-release: + name: Publish helm charts + needs: [ validation ] + runs-on: ubuntu-latest + permissions: + contents: write + pages: write + + if: needs.validation.outputs.RELEASE_VERSION + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Install Helm + uses: azure/setup-helm@v4 + with: + version: v3.8.1 + - name: Package helm, update index.yaml and push to gh-pages + run: | + # Prepare git env + git config user.name "eclipse-tractusx-bot" + git config user.email "tractusx-bot@eclipse.org" + + # Package all charts + find charts -name Chart.yaml -not -path "./edc-tests/*" | xargs -n1 dirname | xargs -n1 helm package -u -d helm-charts + + git checkout gh-pages || git checkout -b gh-pages + git pull --rebase origin gh-pages + + # Generate helm repo index.yaml + helm repo index . --merge index.yaml --url https://${GITHUB_REPOSITORY_OWNER}.github.io/${GITHUB_REPOSITORY#*/}/ + + # Commit and push to gh-pages + git add index.yaml helm-charts + git commit -s -m "Release ${{ needs.validation.outputs.RELEASE_VERSION }}" + + git push origin gh-pages + + # Release: GitHub tag & release; Starts a new development cycle if latest release; + github-release: + name: Publish new github release + needs: [ validation, maven-release, docker-release, helm-release ] + runs-on: ubuntu-latest + permissions: + contents: write + if: needs.validation.outputs.RELEASE_VERSION + steps: + - uses: ./.github/actions/publish-tag-and-release + with: + version: ${{ needs.validation.outputs.RELEASE_VERSION }} + token: ${{ secrets.GITHUB_TOKEN }} + is_latest: ${{ github.ref_name == 'main' }} + + # Release: Publish specs to SwaggerHub + publish-to-swaggerhub: + name: "Publish OpenAPI spec to Swaggerhub" + permissions: + contents: read + needs: [ validation ] + uses: ./.github/workflows/publish-swaggerhub.yaml + with: + downstream-version: ${{ needs.validation.outputs.RELEASE_VERSION }} + secrets: inherit + + # Release: Publish specs to GitHub Pages + publish-openapi-to-gh-pages: + name: "Publish OpenAPI UI spec GitHub Pages" + permissions: + contents: write + needs: [ validation ] + uses: ./.github/workflows/publish-openapi-ui.yml + secrets: inherit + with: + version: ${{ needs.validation.outputs.RELEASE_VERSION }}