Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(workflows): Add publish-bugfix-release workflow to main #1518

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
211 changes: 211 additions & 0 deletions .github/workflows/publish-bugfix-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
#################################################################################
# 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 "[email protected]"
- 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/[email protected]
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 "[email protected]"

# 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 "[email protected]"

# 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 }}
Loading