From 51b506c05414164c528c48e3304981f47de5db3f Mon Sep 17 00:00:00 2001 From: pweick Date: Thu, 27 Jun 2024 10:19:19 +0200 Subject: [PATCH 01/10] refactor(release): removed superfluous step from release workflow again --- .github/workflows/publish-swagger-hub.yml | 50 ----------------------- .github/workflows/release.yaml | 14 +------ 2 files changed, 2 insertions(+), 62 deletions(-) delete mode 100644 .github/workflows/publish-swagger-hub.yml diff --git a/.github/workflows/publish-swagger-hub.yml b/.github/workflows/publish-swagger-hub.yml deleted file mode 100644 index 1fef7d9354..0000000000 --- a/.github/workflows/publish-swagger-hub.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: "Publish OpenAPI to Swaggerhub" - -on: - workflow_call: - inputs: - version: - required: true - description: Version that will be published to Swaggerhub - type: string - -jobs: - swagger-api: - runs-on: ubuntu-latest - env: - SWAGGERHUB_API_KEY: ${{ secrets.SWAGGERHUB_API_KEY }} - SWAGGERHUB_USER: ${{ secrets.SWAGGERHUB_USER }} - DOWNSTREAM_VERSION: ${{ inputs.version }} - steps: - - uses: actions/checkout@v4 - - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'temurin' - - - name: Setup node - uses: actions/setup-node@v4 - - - name: Install Swagger CLI - run: | - npm i -g swaggerhub-cli - - # create API, will fail if exists - - name: Create API - continue-on-error: true - run: | - swaggerhub api:create ${{ env.SWAGGERHUB_USER }}/item-relationship-service/${{ env.DOWNSTREAM_VERSION }} -f docs/src/api/irs-api.yaml --visibility=public --published=unpublish - - # Post the API to SwaggerHub as "unpublished", because published APIs cannot be overwritten - - name: Publish API Specs to SwaggerHub - run: | - if [[ ${{ env.DOWNSTREAM_VERSION }} != *-SNAPSHOT ]]; then - echo "[INFO] - no snapshot, will set the API to 'published'"; - swaggerhub api:update ${{ env.SWAGGERHUB_USER }}/item-relationship-service/${{ env.DOWNSTREAM_VERSION }} -f docs/src/api/irs-api.yaml --visibility=public --published=publish - swaggerhub api:setdefault ${{ env.SWAGGERHUB_USER }}/item-relationship-service/${{ env.DOWNSTREAM_VERSION }} - else - echo "[INFO] - snapshot, will set the API to 'unpublished'"; - swaggerhub api:update ${{ env.SWAGGERHUB_USER }}/item-relationship-service/${{ env.DOWNSTREAM_VERSION }} -f docs/src/api/irs-api.yaml --visibility=public --published=unpublish - fi diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index f6e4f081dd..0ee0147901 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -17,6 +17,7 @@ on: description: 'Add "Update IRS to ..." change to Helm Chart changelog' required: true type: boolean + default: true env: IRS_APPLICATION_PATH: 'irs-api/src/main/java/org/eclipse/tractusx/irs/IrsApplication.java' @@ -206,15 +207,4 @@ jobs: uses: softprops/action-gh-release@v2 with: body: ${{ env.CHANGELOG }} - tag_name: ${{ inputs.irs-version }} - - publish-to-swaggerhub: - name: "Publish OpenAPI spec to Swaggerhub" - permissions: - contents: read - needs: - - release - uses: ./.github/workflows/publish-swagger-hub.yml - with: - version: ${{ inputs.irs-version }} - secrets: inherit \ No newline at end of file + tag_name: ${{ inputs.irs-version }} \ No newline at end of file From 72dadc8bbc582985002d20f5471d63bdfeade66d Mon Sep 17 00:00:00 2001 From: pweick Date: Thu, 27 Jun 2024 10:44:25 +0200 Subject: [PATCH 02/10] fix(release): release workflow makes sure to call other workflows --- .github/workflows/helm-chart-release.yaml | 1 + .github/workflows/irs-build.yml | 1 + .github/workflows/release.yaml | 35 +++++++++++++++++-- .github/workflows/swagger-editor-validate.yml | 1 + .github/workflows/trivy-image-scan.yml | 1 + 5 files changed, 37 insertions(+), 2 deletions(-) diff --git a/.github/workflows/helm-chart-release.yaml b/.github/workflows/helm-chart-release.yaml index 529bdd3289..0df2595512 100644 --- a/.github/workflows/helm-chart-release.yaml +++ b/.github/workflows/helm-chart-release.yaml @@ -2,6 +2,7 @@ name: Release Helm Charts on: workflow_dispatch: # Trigger manually + workflow_call: push: branches: - main diff --git a/.github/workflows/irs-build.yml b/.github/workflows/irs-build.yml index 21cdfb8d3b..662f321822 100644 --- a/.github/workflows/irs-build.yml +++ b/.github/workflows/irs-build.yml @@ -2,6 +2,7 @@ name: IRS build on: workflow_dispatch: # Trigger manually + workflow_call: pull_request: paths-ignore: - '**/*.md' diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 0ee0147901..180f283378 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -150,7 +150,7 @@ jobs: pull_request_merged="False" seconds_waited_for_merge=0 # set duration between api requests - sleep_interval_length=30 # seconds + sleep_interval_length=5 # seconds timeout_in_minutes=15 echo "Waiting for merge of PR #$pull_request_number." @@ -207,4 +207,35 @@ jobs: uses: softprops/action-gh-release@v2 with: body: ${{ env.CHANGELOG }} - tag_name: ${{ inputs.irs-version }} \ No newline at end of file + tag_name: ${{ inputs.irs-version }} + + release-helm-chart: + name: "Release Helm chart" + needs: + - release + uses: ./.github/workflows/helm-chart-release.yaml + if: ${{ github.ref_name != 'main' }} # triggered automatically on main + + build-irs: + name: "Build IRS" + needs: + - release + uses: ./.github/workflows/irs-build.yml + secrets: inherit + if: ${{ github.ref_name != 'main' }} # triggered automatically on main + + trivy-image-scan: + name: "Scan image in local registry with Trivy" + needs: + - release + uses: ./.github/workflows/trivy-image-scan.yml + secrets: inherit + if: ${{ github.ref_name != 'main' }} # triggered automatically on main + + validate-openapi-definition: + needs: + - release + name: "Validate OpenAPI definition" + uses: ./.github/workflows/swagger-editor-validate.yml + secrets: inherit + if: ${{ github.ref_name != 'main' }} # triggered automatically on main \ No newline at end of file diff --git a/.github/workflows/swagger-editor-validate.yml b/.github/workflows/swagger-editor-validate.yml index efcecb035f..23a09949fa 100644 --- a/.github/workflows/swagger-editor-validate.yml +++ b/.github/workflows/swagger-editor-validate.yml @@ -2,6 +2,7 @@ name: "Validate OpenAPI definition" on: workflow_dispatch: # Trigger manually + workflow_call: pull_request: push: branches: diff --git a/.github/workflows/trivy-image-scan.yml b/.github/workflows/trivy-image-scan.yml index 27fe9c8719..bfaf93381d 100644 --- a/.github/workflows/trivy-image-scan.yml +++ b/.github/workflows/trivy-image-scan.yml @@ -5,6 +5,7 @@ name: "Trivy vulnerability scanner for image" on: workflow_dispatch: # Trigger manually + workflow_call: pull_request: paths-ignore: - '**/*.md' From 4f20c1467774730c633a557be9b4a30366466867 Mon Sep 17 00:00:00 2001 From: pweick Date: Thu, 27 Jun 2024 12:45:03 +0200 Subject: [PATCH 03/10] chore(docs): update CONTRIBUTING.md for new release workflow --- CONTRIBUTING.md | 105 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 76 insertions(+), 29 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 64994e7a02..1483601ae9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,6 +3,7 @@ Thanks for your interest in this project. # Table of Contents + 1. [Project description](#project-description) 2. [Project licenses](#project-licenses) 3. [Terms of Use](#terms-of-use) @@ -88,7 +89,9 @@ See [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md). ## Eclipse Dependency License Check -In case of new dependencies or version updates, it might be necessary to have the new library checked and accepted by the Eclipse foundation. Do create new tickets for this, you can use this command: +In case of new dependencies or version updates, it might be necessary to have the new library checked and accepted by +the Eclipse foundation. Do create new tickets for this, you can use this command: + ``` mvn org.eclipse.dash:license-tool-plugin:license-check -Ddash.iplab.token=$ECLIPSE_DASH_TOKEN -Ddash.projectId=automotive.tractusx --batch-mode -DskipTests -P dash ``` @@ -99,30 +102,37 @@ For more information on the tool and how to acquire the token, check https://git General contributions e.g. contributions to improve documentation are welcome. If you need ideas for contributions, you can check the following links: + - [open documentation stories](https://github.com/orgs/eclipse-tractusx/projects/8/views/4?filterQuery=label%3Adocumentation++status%3Ainbox%2Cbacklog) - [discussion page concerning documentation improvements](https://github.com/eclipse-tractusx/item-relationship-service/discussions/407) -### Maintaining [CHANGELOG.md](CHANGELOG.md) +### Maintaining [CHANGELOG.md](CHANGELOG.md) + All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres -to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). _**For better traceability add the corresponding GitHub issue number in each changelog entry, please.**_ ## Contributing as a Consultant ### Conceptual work and specification guidelines -1. The prerequisite for a concept is always a GitHub issue that defines the business value and the acceptance criteria that are to be implemented with the concept + +1. The prerequisite for a concept is always a GitHub issue that defines the business value and the acceptance criteria + that are to be implemented with the concept 2. Copy and rename directory /docs/#000-concept-name-template /docs/#- -3. Copy the template file [/docs/concept/TEMPLATE_Concept.md](docs/concept/TEMPLATE_Concept.md) into new directory `/docs/#-`. +3. Copy the template file [/docs/concept/TEMPLATE_Concept.md](docs/concept/TEMPLATE_Concept.md) into new + directory `/docs/#-`. ### Diagrams + [PlantUML](https://plantuml.com/) and [Mermaid](https://mermaid.js.org/) is used for conceptual work. +#### PlantUML + +default skinparam for plantUml diagrams -#### PlantUML -default skinparam for plantUml diagrams ```` @startuml skinparam monochrome true @@ -134,8 +144,10 @@ autonumber "[000]" @enduml ```` -#### Mermaid +#### Mermaid + Default header for mermaid sequence diagrams + ```` sequenceDiagram %%{init: {'theme': 'dark', 'themeVariables': { 'fontSize': '15px'}}}%% @@ -157,6 +169,7 @@ Example: Detailed pattern can be found here: [commit-msg](local/development/commit-msg) #### How to Use + ```shell cp local/development/commit-msg .git/hooks/commit-msg && chmod 500 .git/hooks/commit-msg ``` @@ -166,11 +179,15 @@ For further information please see https://github.com/hazcod/semantic-commit-hoo ### Code Formatting #### Deprecated soon: + Please use the following code formatter: [.idea/codeStyles](.idea/codeStyles) -#### Upcoming change (not available until whole project base will be formatted to new standard): +#### Upcoming change (not available until whole project base will be formatted to new standard): + Google Java Format will be used as code format standard. -Please install `google-java-format` plugin and edit customer VM options (for IntelliJ `Help → Edit Custom VM Options...`) and paste following configuration: +Please install `google-java-format` plugin and edit customer VM options (for +IntelliJ `Help → Edit Custom VM Options...`) and paste following configuration: + ``` -Xmx4096m --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED @@ -180,7 +197,11 @@ Please install `google-java-format` plugin and edit customer VM options (for Int --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED ``` -The plugin will be disabled by default. To enable it in the current project, go to `File→Settings...→google-java-format` Settings (or `IntelliJ IDEA→Preferences...→Other Settings→google-java-format` Settings on macOS) and check the Enable google-java-format checkbox. (A notification will be presented when you first open a project offering to do this for you.) + +The plugin will be disabled by default. To enable it in the current project, go to `File→Settings...→google-java-format` +Settings (or `IntelliJ IDEA→Preferences...→Other Settings→google-java-format` Settings on macOS) and check the Enable +google-java-format checkbox. (A notification will be presented when you first open a project offering to do this for +you.) More info: https://github.com/google/google-java-format/blob/master/README.md#intellij-jre-config @@ -194,40 +215,66 @@ https://github.com/google/google-java-format/blob/master/README.md#intellij-jre- 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)) - - Check if the changelog entries for the release are complete. - - Add the corresponding GitHub issue numbers to each entry if missing. + - 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). + +#### Procedure used before July 1, 2024 + 4. Update IRS API version in IrsApplication class and irs-api.yaml -5. Create pull request from [release preparation branch to main](https://github.com/eclipse-tractusx/item-relationship-service/compare/chore/prepare-release-x.x.x) +5. Create pull request + from [release preparation branch to main](https://github.com/eclipse-tractusx/item-relationship-service/compare/chore/prepare-release-x.x.x) 6. Merge this pull request to main. 7. Create Git tag for the desired release version `git tag x.x.x` - (note: the _item-relationship-service_ tag will be created automatically by the GitHub workflow based on the version in the [helm chart changelog](charts/item-relationship-service/CHANGELOG.md)). + (note: the _item-relationship-service_ tag will be created automatically by the GitHub workflow based on the version + in the [helm chart changelog](charts/item-relationship-service/CHANGELOG.md)). 8. Push Git tag to repository `git push origin x.x.x` (this will trigger the GitHub release workflow). 9. Wait for release workflow to complete. 10. Merge the pull request that was automatically opened by GitHub actions bot. -11. Notify about the release in IRS Matrix Chat using the following template: - - > **IRS Release x.x.x** - > - > IRS version x.x.x is released. - > - > https://github.com/eclipse-tractusx/item-relationship-service/releases/tag/x.x.x
- > https://github.com/eclipse-tractusx/item-relationship-service/releases/tag/item-relationship-service-y.y.y
- > **Full Changelog:** https://github.com/eclipse-tractusx/item-relationship-service/compare/w.w.w...x.x.x - _(replace x.x.x with IRS version to release, y.y.y with IRS helm version to release and w.w.w with previous IRS version)_ +#### Procedure used starting July 1, 2024 + +Starting July 1, 2024, a new version of the release workflow is used which automates the changes that previously +had to be done by hand. + +4. Execute the workflow named _"Release IRS"_. 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 the 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. -#### Release chart only +#### Regardless of performed preceding procedure + +Notify about the release in IRS Matrix Chat using the following template: + +> **IRS Release x.x.x** +> +> IRS version x.x.x is released. +> +> https://github.com/eclipse-tractusx/item-relationship-service/releases/tag/x.x.x
+> https://github.com/eclipse-tractusx/item-relationship-service/releases/tag/item-relationship-service-y.y.y
+> **Full Changelog:** https://github.com/eclipse-tractusx/item-relationship-service/compare/w.w.w...x.x.x + +_(replace x.x.x with IRS version to release, y.y.y with Helm Chart version to release and w.w.w with previous IRS +version)_ + +#### Release Helm chart only 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/release-chart-x.x.x`. 2. Add new version to [charts/item-relationship-service/CHANGELOG.md](charts/item-relationship-service/CHANGELOG.md) -3. Change chart version in [Chart.yaml](charts/item-relationship-service/Chart.yaml) -4. Create pull request from [release preparation branch to main](https://github.com/eclipse-tractusx/item-relationship-service/compare/chore/release-chart-x.x.x) +3. Change chart version in [Chart.yaml](charts/item-relationship-service/Chart.yaml) +4. Create pull request + from [release preparation branch to main](https://github.com/eclipse-tractusx/item-relationship-service/compare/chore/release-chart-x.x.x) 5. Merge this pull request to main. 6. Wait for release workflow to complete. - ## Contact See [CONTACT](CONTACT.md) From be40ec46466c6e13096f555f85904c6515a6a9a8 Mon Sep 17 00:00:00 2001 From: pweick Date: Wed, 3 Jul 2024 08:55:21 +0200 Subject: [PATCH 04/10] chore(docs): update CONTRIBUTING.md for new release workflow --- CONTRIBUTING.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1483601ae9..bae3b1eb6a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -219,7 +219,7 @@ https://github.com/google/google-java-format/blob/master/README.md#intellij-jre- - Add the corresponding GitHub issue numbers to each entry if missing. 3. Update [COMPATIBILITY_MATRIX.md](COMPATIBILITY_MATRIX.md). -#### Procedure used before July 1, 2024 +#### Old way of creating a release 4. Update IRS API version in IrsApplication class and irs-api.yaml 5. Create pull request @@ -232,12 +232,12 @@ https://github.com/google/google-java-format/blob/master/README.md#intellij-jre- 9. Wait for release workflow to complete. 10. Merge the pull request that was automatically opened by GitHub actions bot. -#### Procedure used starting July 1, 2024 +#### New way of creating a release -Starting July 1, 2024, a new version of the release workflow is used which automates the changes that previously +A new version of the release workflow is used which automates the changes that previously had to be done by hand. -4. Execute the workflow named _"Release IRS"_. The workflow takes three inputs. These are: +4. Execute the workflow named _"Release IRS"_ from the created `chore` branch. 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 From 88170300d990300cbd292da7cfa2dac702fa9145 Mon Sep 17 00:00:00 2001 From: pweick Date: Wed, 3 Jul 2024 09:28:28 +0200 Subject: [PATCH 05/10] chore(docs): updated CONTRIBUTING.md for new release workflow --- CONTRIBUTING.md | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bae3b1eb6a..972e37eb02 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -208,7 +208,7 @@ https://github.com/google/google-java-format/blob/master/README.md#intellij-jre- ### Create a Release -#### Full release +### Full release 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`. @@ -218,40 +218,18 @@ https://github.com/google/google-java-format/blob/master/README.md#intellij-jre- - 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). - -#### Old way of creating a release - -4. Update IRS API version in IrsApplication class and irs-api.yaml -5. Create pull request - from [release preparation branch to main](https://github.com/eclipse-tractusx/item-relationship-service/compare/chore/prepare-release-x.x.x) -6. Merge this pull request to main. -7. Create Git tag for the desired release version `git tag x.x.x` - (note: the _item-relationship-service_ tag will be created automatically by the GitHub workflow based on the version - in the [helm chart changelog](charts/item-relationship-service/CHANGELOG.md)). -8. Push Git tag to repository `git push origin x.x.x` (this will trigger the GitHub release workflow). -9. Wait for release workflow to complete. -10. Merge the pull request that was automatically opened by GitHub actions bot. - -#### New way of creating a release - -A new version of the release workflow is used which automates the changes that previously -had to be done by hand. - -4. Execute the workflow named _"Release IRS"_ from the created `chore` branch. The workflow takes three inputs. These are: +4. Execute the workflow named _"Release IRS"_. 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 the automated changes and creates a pull request from them right away. +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. - -#### Regardless of performed preceding procedure - -Notify about the release in IRS Matrix Chat using the following template: +7. Notify about the release in IRS Matrix Chat using the following template: > **IRS Release x.x.x** > @@ -264,7 +242,7 @@ Notify about the release in IRS Matrix Chat using the following template: _(replace x.x.x with IRS version to release, y.y.y with Helm Chart version to release and w.w.w with previous IRS version)_ -#### Release Helm chart only +### Release Helm chart only 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/release-chart-x.x.x`. From 8afb635bbca5506a27c19b8176d09e335e644150 Mon Sep 17 00:00:00 2001 From: pweick Date: Wed, 3 Jul 2024 13:39:43 +0200 Subject: [PATCH 06/10] fix(release): release workflow executes subsequent workflows correctly --- .github/workflows/helm-chart-release.yaml | 34 ++++++++++++++++++- .github/workflows/release.yaml | 16 ++++++--- .github/workflows/swagger-editor-validate.yml | 34 ++++++++++++++++++- .github/workflows/trivy-image-scan.yml | 32 ++++++++++++++++- 4 files changed, 109 insertions(+), 7 deletions(-) diff --git a/.github/workflows/helm-chart-release.yaml b/.github/workflows/helm-chart-release.yaml index 0df2595512..fbe491edd5 100644 --- a/.github/workflows/helm-chart-release.yaml +++ b/.github/workflows/helm-chart-release.yaml @@ -3,6 +3,17 @@ name: Release Helm Charts on: workflow_dispatch: # Trigger manually workflow_call: + inputs: + checkout-tag: + description: 'Whether to check out a tag' + required: false + type: boolean + default: false + + ref-to-checkout: + description: 'Ref of branch/tag from which to execute workflow' + required: true + type: string push: branches: - main @@ -10,7 +21,22 @@ on: - 'charts/**' jobs: + determine-ref: + runs-on: ubuntu-latest + outputs: + ref: ${{ steps.determine-ref.outputs.ref }} + steps: + - name: Determine ref to check out + id: determine-ref + run: | + if [[ "${{ inputs.checkout-tag }}" == "false" ]]; then + echo "ref=${{ github.ref }}" >> "$GITHUB_OUTPUT" + else + echo "ref=${{ inputs.ref-to-checkout }}" >> "$GITHUB_OUTPUT" + fi + get-helm-charts-versions-irs: + needs: determine-ref outputs: latest_version: ${{ steps.step1.outputs.latest_version }} current_version: ${{ steps.step2.outputs.current_version }} @@ -22,6 +48,9 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + fetch-tags: 'true' + + - run: git checkout ${{ needs.determine-ref.outputs.ref }} - name: Get helm charts latest tag version id: step1 @@ -37,7 +66,7 @@ jobs: echo "Exported $chartVersion helm charts version" release: - needs: "get-helm-charts-versions-irs" + needs: [get-helm-charts-versions-irs, determine-ref] if: needs.get-helm-charts-versions-irs.outputs.latest_version != needs.get-helm-charts-versions-irs.outputs.current_version # depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions # see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token @@ -49,6 +78,9 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + fetch-tags: 'true' + + - run: git checkout ${{ needs.determine-ref.outputs.ref }} - name: Configure Git run: | diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 180f283378..a8a536d1e4 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -214,7 +214,9 @@ jobs: needs: - release uses: ./.github/workflows/helm-chart-release.yaml - if: ${{ github.ref_name != 'main' }} # triggered automatically on main + with: + checkout-tag: true + ref-to-checkout: '${{ inputs.irs-version }}' build-irs: name: "Build IRS" @@ -222,7 +224,9 @@ jobs: - release uses: ./.github/workflows/irs-build.yml secrets: inherit - if: ${{ github.ref_name != 'main' }} # triggered automatically on main + with: + checkout-tag: true + ref-to-checkout: '${{ inputs.irs-version }}' trivy-image-scan: name: "Scan image in local registry with Trivy" @@ -230,7 +234,9 @@ jobs: - release uses: ./.github/workflows/trivy-image-scan.yml secrets: inherit - if: ${{ github.ref_name != 'main' }} # triggered automatically on main + with: + checkout-tag: true + ref-to-checkout: '${{ inputs.irs-version }}' validate-openapi-definition: needs: @@ -238,4 +244,6 @@ jobs: name: "Validate OpenAPI definition" uses: ./.github/workflows/swagger-editor-validate.yml secrets: inherit - if: ${{ github.ref_name != 'main' }} # triggered automatically on main \ No newline at end of file + with: + checkout-tag: true + ref-to-checkout: '${{ inputs.irs-version }}' \ No newline at end of file diff --git a/.github/workflows/swagger-editor-validate.yml b/.github/workflows/swagger-editor-validate.yml index 23a09949fa..49d3dac914 100644 --- a/.github/workflows/swagger-editor-validate.yml +++ b/.github/workflows/swagger-editor-validate.yml @@ -3,6 +3,17 @@ name: "Validate OpenAPI definition" on: workflow_dispatch: # Trigger manually workflow_call: + inputs: + checkout-tag: + description: 'Whether to check out a tag' + required: false + type: boolean + default: false + + ref-to-checkout: + description: 'Ref of branch/tag from which to execute workflow' + required: true + type: string pull_request: push: branches: @@ -11,12 +22,33 @@ on: - '**' jobs: + determine-ref: + runs-on: ubuntu-latest + outputs: + ref: ${{ steps.determine-ref.outputs.ref }} + steps: + - name: Determine ref to check out + id: determine-ref + run: | + if [[ "${{ inputs.checkout-tag }}" == "false" ]]; then + echo "ref=${{ github.ref }}" >> "$GITHUB_OUTPUT" + else + echo "ref=${{ inputs.ref-to-checkout }}" >> "$GITHUB_OUTPUT" + fi + test_swagger_editor_validator_remote: runs-on: ubuntu-latest + needs: determine-ref name: Swagger Editor Validator Remote steps: - - uses: actions/checkout@v4 + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-tags: 'true' + + - run: git checkout ${{ needs.determine-ref.outputs.ref }} + - name: Validate OpenAPI definition uses: char0n/swagger-editor-validate@v1 with: diff --git a/.github/workflows/trivy-image-scan.yml b/.github/workflows/trivy-image-scan.yml index f815896ca5..fb84220873 100644 --- a/.github/workflows/trivy-image-scan.yml +++ b/.github/workflows/trivy-image-scan.yml @@ -6,6 +6,17 @@ name: "Trivy vulnerability scanner for image" on: workflow_dispatch: # Trigger manually workflow_call: + inputs: + checkout-tag: + description: 'Whether to check out a tag' + required: false + type: boolean + default: false + + ref-to-checkout: + description: 'Ref of branch/tag from which to execute workflow' + required: true + type: string pull_request: paths-ignore: - '**/*.md' @@ -23,8 +34,23 @@ on: - cron: '0 0 * * *' # Once a day jobs: + determine-ref: + runs-on: ubuntu-latest + outputs: + ref: ${{ steps.determine-ref.outputs.ref }} + steps: + - name: Determine ref to check out + id: determine-ref + run: | + if [[ "${{ inputs.checkout-tag }}" == "false" ]]; then + echo "ref=${{ github.ref }}" >> "$GITHUB_OUTPUT" + else + echo "ref=${{ inputs.ref-to-checkout }}" >> "$GITHUB_OUTPUT" + fi + analyze-irs-api: runs-on: ubuntu-latest + needs: determine-ref permissions: actions: read contents: read @@ -36,8 +62,12 @@ jobs: - 5000:5000 steps: - - name: Checkout repository + - name: Checkout uses: actions/checkout@v4 + with: + fetch-tags: 'true' + + - run: git checkout ${{ needs.determine-ref.outputs.ref }} - name: Build image uses: docker/build-push-action@v6 From b83d697e1b6f1cdc42bfa2fbcf6f4ed8d3a72810 Mon Sep 17 00:00:00 2001 From: pweick Date: Wed, 3 Jul 2024 13:43:08 +0200 Subject: [PATCH 07/10] refactor(docs): cleaned up dummy changes in CHANGELOG.md --- CHANGELOG.md | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 874cac105c..af2dcfd328 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,18 +8,6 @@ _**For better traceability add the corresponding GitHub issue number in each cha ## [Unreleased] -## [5.1.9] - 2024-06-27 - -### Added - -- soemthing was added - -### Changed - -- and something else was changed - -## [5.1.5] - 2024-06-27 - ### Fixed - Fixed ESS Investigation job processing not starting #579 From 66fae6bb812b859eb565ea6c6abbf662b48f2b50 Mon Sep 17 00:00:00 2001 From: pweick Date: Wed, 3 Jul 2024 13:51:44 +0200 Subject: [PATCH 08/10] fix(release): release workflow executes subsequent workflows correctly --- .github/workflows/irs-build.yml | 42 +++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/.github/workflows/irs-build.yml b/.github/workflows/irs-build.yml index c35a59c501..6f1336f74f 100644 --- a/.github/workflows/irs-build.yml +++ b/.github/workflows/irs-build.yml @@ -3,6 +3,18 @@ name: IRS build on: workflow_dispatch: # Trigger manually workflow_call: + inputs: + checkout-tag: + description: 'Whether to check out a tag' + required: false + type: boolean + default: false + + ref-to-checkout: + description: 'Ref of branch/tag from which to execute workflow' + required: true + type: string + pull_request: paths-ignore: - '**/*.md' @@ -20,6 +32,20 @@ on: - '**' jobs: + determine-ref: + runs-on: ubuntu-latest + outputs: + ref: ${{ steps.determine-ref.outputs.ref }} + steps: + - name: Determine ref to check out + id: determine-ref + run: | + if [[ "${{ inputs.checkout-tag }}" == "false" ]]; then + echo "ref=${{ github.ref }}" >> "$GITHUB_OUTPUT" + else + echo "ref=${{ inputs.ref-to-checkout }}" >> "$GITHUB_OUTPUT" + fi + init: runs-on: ubuntu-latest outputs: @@ -35,9 +61,14 @@ jobs: build: runs-on: ubuntu-latest + needs: determine-ref steps: - name: Checkout repository uses: actions/checkout@v4 + with: + fetch-tags: 'true' + + - run: git checkout ${{ needs.determine-ref.outputs.ref }} - name: Set up JDK 17 uses: actions/setup-java@v4 @@ -57,7 +88,7 @@ jobs: mvn clean verify --batch-mode analyze_with_Sonar: - needs: [init] + needs: [init, determine-ref] # No need to run if we cannot use the sonar token if: >- needs.init.outputs.sonar_configured == 'true' @@ -68,6 +99,9 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of sonar analysis + fetch-tags: 'true' + + - run: git checkout ${{ needs.determine-ref.outputs.ref }} - name: Set up JDK 17 uses: actions/setup-java@v4 @@ -100,7 +134,7 @@ jobs: -Dcheckstyle.skip -Dpmd.skip=true build_images: - needs: [init] + needs: [init, determine-ref] strategy: matrix: image: @@ -110,6 +144,10 @@ jobs: image-tag: ${{ steps.version.outputs.image_tag }} steps: - uses: actions/checkout@v4 + with: + fetch-tags: 'true' + + - run: git checkout ${{ needs.determine-ref.outputs.ref }} - name: Build image to make sure Dockerfile is valid run: | From 663adfea33e722999db24c36c8745052477eb471 Mon Sep 17 00:00:00 2001 From: pweick Date: Wed, 3 Jul 2024 14:19:33 +0200 Subject: [PATCH 09/10] refactor(release): clean up dummy changes from various files --- CHANGELOG.md | 4 +--- charts/item-relationship-service/CHANGELOG.md | 12 ------------ charts/item-relationship-service/Chart.yaml | 4 ++-- .../org/eclipse/tractusx/irs/IrsApplication.java | 2 +- 4 files changed, 4 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af2dcfd328..ceaa7fceb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -698,9 +698,7 @@ _**For better traceability add the corresponding GitHub issue number in each cha - **Select Aspects you need** You are able to select the needed aspects for which you want to collect the correct endpoint information. -[Unreleased]: https://github.com/eclipse-tractusx/item-relationship-service/compare/5.1.9...HEAD -[5.1.9]: https://github.com/eclipse-tractusx/item-relationship-service/compare/5.1.5...5.1.9 -[5.1.5]: https://github.com/eclipse-tractusx/item-relationship-service/compare/5.1.4...5.1.5 +[Unreleased]: https://github.com/eclipse-tractusx/item-relationship-service/compare/5.1.4...HEAD [5.1.4]: https://github.com/eclipse-tractusx/item-relationship-service/compare/5.1.3...5.1.4 [5.1.3]: https://github.com/eclipse-tractusx/item-relationship-service/compare/5.1.2...5.1.3 [5.1.2]: https://github.com/eclipse-tractusx/item-relationship-service/compare/5.1.1...5.1.2 diff --git a/charts/item-relationship-service/CHANGELOG.md b/charts/item-relationship-service/CHANGELOG.md index e5ab1537f2..3392764545 100644 --- a/charts/item-relationship-service/CHANGELOG.md +++ b/charts/item-relationship-service/CHANGELOG.md @@ -6,18 +6,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -## [7.1.9] - 2024-06-27 - -### Changed - -- Update IRS version to 5.1.9 - -## [7.1.5] - 2024-06-27 - -### Changed - -- Update IRS version to 5.1.5 - ## [7.1.4] - 2024-05-27 diff --git a/charts/item-relationship-service/Chart.yaml b/charts/item-relationship-service/Chart.yaml index c93fb20be5..5eb5360ab9 100644 --- a/charts/item-relationship-service/Chart.yaml +++ b/charts/item-relationship-service/Chart.yaml @@ -35,12 +35,12 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 7.1.9 +version: 7.1.4 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "5.1.9" +appVersion: "5.1.4" dependencies: - name: common repository: https://charts.bitnami.com/bitnami diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/IrsApplication.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/IrsApplication.java index aa8b34ed44..e37f31b068 100644 --- a/irs-api/src/main/java/org/eclipse/tractusx/irs/IrsApplication.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/IrsApplication.java @@ -59,7 +59,7 @@ public class IrsApplication { /** * The IRS API version. */ - public static final String API_VERSION = "5.1.9"; + public static final String API_VERSION = "5.1.4"; /** * The URL prefix for IRS API URLs. From 1d498d4885419408d529e1f28eb43461742f5dbc Mon Sep 17 00:00:00 2001 From: pweick Date: Wed, 3 Jul 2024 14:32:54 +0200 Subject: [PATCH 10/10] fix(release): release workflow executes subsequent workflows correctly --- .github/workflows/helm-chart-release.yaml | 6 ++---- .github/workflows/irs-build.yml | 9 +++------ .github/workflows/release.yaml | 8 ++++---- .github/workflows/swagger-editor-validate.yml | 3 +-- .github/workflows/trivy-image-scan.yml | 3 +-- 5 files changed, 11 insertions(+), 18 deletions(-) diff --git a/.github/workflows/helm-chart-release.yaml b/.github/workflows/helm-chart-release.yaml index fbe491edd5..adc2bf6b48 100644 --- a/.github/workflows/helm-chart-release.yaml +++ b/.github/workflows/helm-chart-release.yaml @@ -49,8 +49,7 @@ jobs: with: fetch-depth: 0 fetch-tags: 'true' - - - run: git checkout ${{ needs.determine-ref.outputs.ref }} + ref: ${{ needs.determine-ref.outputs.ref }} - name: Get helm charts latest tag version id: step1 @@ -79,8 +78,7 @@ jobs: with: fetch-depth: 0 fetch-tags: 'true' - - - run: git checkout ${{ needs.determine-ref.outputs.ref }} + ref: ${{ needs.determine-ref.outputs.ref }} - name: Configure Git run: | diff --git a/.github/workflows/irs-build.yml b/.github/workflows/irs-build.yml index 6f1336f74f..19af9e2661 100644 --- a/.github/workflows/irs-build.yml +++ b/.github/workflows/irs-build.yml @@ -67,8 +67,7 @@ jobs: uses: actions/checkout@v4 with: fetch-tags: 'true' - - - run: git checkout ${{ needs.determine-ref.outputs.ref }} + ref: ${{ needs.determine-ref.outputs.ref }} - name: Set up JDK 17 uses: actions/setup-java@v4 @@ -100,8 +99,7 @@ jobs: with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of sonar analysis fetch-tags: 'true' - - - run: git checkout ${{ needs.determine-ref.outputs.ref }} + ref: ${{ needs.determine-ref.outputs.ref }} - name: Set up JDK 17 uses: actions/setup-java@v4 @@ -146,8 +144,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-tags: 'true' - - - run: git checkout ${{ needs.determine-ref.outputs.ref }} + ref: ${{ needs.determine-ref.outputs.ref }} - name: Build image to make sure Dockerfile is valid run: | diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a8a536d1e4..7484a1f908 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -216,7 +216,7 @@ jobs: uses: ./.github/workflows/helm-chart-release.yaml with: checkout-tag: true - ref-to-checkout: '${{ inputs.irs-version }}' + ref-to-checkout: 'refs/tags/${{ inputs.irs-version }}' build-irs: name: "Build IRS" @@ -226,7 +226,7 @@ jobs: secrets: inherit with: checkout-tag: true - ref-to-checkout: '${{ inputs.irs-version }}' + ref-to-checkout: 'refs/tags/${{ inputs.irs-version }}' trivy-image-scan: name: "Scan image in local registry with Trivy" @@ -236,7 +236,7 @@ jobs: secrets: inherit with: checkout-tag: true - ref-to-checkout: '${{ inputs.irs-version }}' + ref-to-checkout: 'refs/tags/${{ inputs.irs-version }}' validate-openapi-definition: needs: @@ -246,4 +246,4 @@ jobs: secrets: inherit with: checkout-tag: true - ref-to-checkout: '${{ inputs.irs-version }}' \ No newline at end of file + ref-to-checkout: 'refs/tags/${{ inputs.irs-version }}' \ No newline at end of file diff --git a/.github/workflows/swagger-editor-validate.yml b/.github/workflows/swagger-editor-validate.yml index 49d3dac914..3a37426900 100644 --- a/.github/workflows/swagger-editor-validate.yml +++ b/.github/workflows/swagger-editor-validate.yml @@ -46,8 +46,7 @@ jobs: uses: actions/checkout@v4 with: fetch-tags: 'true' - - - run: git checkout ${{ needs.determine-ref.outputs.ref }} + ref: ${{ needs.determine-ref.outputs.ref }} - name: Validate OpenAPI definition uses: char0n/swagger-editor-validate@v1 diff --git a/.github/workflows/trivy-image-scan.yml b/.github/workflows/trivy-image-scan.yml index fb84220873..c0bca2012a 100644 --- a/.github/workflows/trivy-image-scan.yml +++ b/.github/workflows/trivy-image-scan.yml @@ -66,8 +66,7 @@ jobs: uses: actions/checkout@v4 with: fetch-tags: 'true' - - - run: git checkout ${{ needs.determine-ref.outputs.ref }} + ref: ${{ needs.determine-ref.outputs.ref }} - name: Build image uses: docker/build-push-action@v6