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): Adds workflow to release hotfix version #1511

267 changes: 267 additions & 0 deletions .github/workflows/publish-hotfix-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
#################################################################################
# Copyright (c) 2021,2023 Contributors to the Eclipse Foundation
rafaelmag110 marked this conversation as resolved.
Show resolved Hide resolved
#
# 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 hotfix 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 hotfix branch is created and all needed PRs are merged

on:
workflow_dispatch:
inputs:
version:
description: 'The hotfix version you want to release.'
required: true

jobs:
# Gate: Check release version presence
validate-release:
name: Validate if hotfix can be released
runs-on: ubuntu-latest
if: startsWith(github.ref_name, 'hotfix/')
rafaelmag110 marked this conversation as resolved.
Show resolved Hide resolved
steps:
- uses: mukunku/[email protected]
id: check-tag
with:
tag: ${{ inputs.version }}

- if: steps.check-tag.outputs.exists == 'true'
name: Exit on tag existance
run: |
echo "Tag already exists! Please choose another tag."
exit 1

release-version:
name: Determine release version
rafaelmag110 marked this conversation as resolved.
Show resolved Hide resolved
needs: [validate-release]
runs-on: ubuntu-latest
outputs:
RELEASE_VERSION: ${{ steps.release-version.outputs.RELEASE_VERSION }}
steps:
- name: Output release version
id: release-version
run: |
echo "RELEASE_VERSION=${{ inputs.version }}" >> $GITHUB_OUTPUT

prepare-hotfix-release:
name: "Prepare hotfix release"
runs-on: ubuntu-latest
needs: [release-version]
permissions:
contents: write
packages: write
rafaelmag110 marked this conversation as resolved.
Show resolved Hide resolved
pages: write
pull-requests: write
if: needs.release-version.outputs.RELEASE_VERSION
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=${{ needs.release-version.outputs.RELEASE_VERSION }}/g' gradle.properties
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 = "${{ needs.release-version.outputs.RELEASE_VERSION }}" | .version = "${{ needs.release-version.outputs.RELEASE_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 ${{ needs.release-version.outputs.RELEASE_VERSION }}"

echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
rafaelmag110 marked this conversation as resolved.
Show resolved Hide resolved

# Release: Maven Artifacts
maven-release:
name: Publish extension's release version to maven repository
wolf4ood marked this conversation as resolved.
Show resolved Hide resolved
needs: [ prepare-hotfix-release, release-version ]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
rafaelmag110 marked this conversation as resolved.
Show resolved Hide resolved
if: needs.release-version.outputs.RELEASE_VERSION
steps:
- name: Export RELEASE_VERSION env
run: |
echo "RELEASE_VERSION=${{ needs.release-version.outputs.RELEASE_VERSION }}" >> $GITHUB_ENV

# Set-Up
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-java

# Import GPG Key
- uses: ./.github/actions/import-gpg-key
name: "Import GPG Key"
with:
gpg-private-key: ${{ secrets.ORG_GPG_PRIVATE_KEY }}

# publish releases
- name: Publish version
env:
OSSRH_PASSWORD: ${{ secrets.ORG_OSSRH_PASSWORD }}
OSSRH_USER: ${{ secrets.ORG_OSSRH_USERNAME }}
run: |-
echo "Publishing Version $RELEASE_VERSION to Sonatype/MavenCentral"
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository --no-parallel -Pversion=$RELEASE_VERSION -Psigning.gnupg.executable=gpg -Psigning.gnupg.passphrase="${{ secrets.ORG_GPG_PASSPHRASE }}"

docker-release:
name: Publish Docker images
runs-on: ubuntu-latest
needs: [ prepare-hotfix-release, release-version ]
permissions:
contents: write
if: needs.release-version.outputs.RELEASE_VERSION

strategy:
fail-fast: false
matrix:
variant: [ { dir: edc-controlplane, img: edc-runtime-memory },
{ dir: edc-controlplane, img: edc-controlplane-postgresql-hashicorp-vault },
{ dir: edc-controlplane, img: edc-controlplane-postgresql-azure-vault },
{ dir: edc-dataplane, img: edc-dataplane-azure-vault },
{ dir: edc-dataplane, img: edc-dataplane-hashicorp-vault },
{ dir: edc-tests/runtime, img: mock-connector }]
steps:
- uses: actions/checkout@v4
- name: Export RELEASE_VERSION env
run: |
echo "RELEASE_VERSION=${{ needs.release-version.outputs.RELEASE_VERSION }}" >> $GITHUB_ENV
rafaelmag110 marked this conversation as resolved.
Show resolved Hide resolved
- uses: ./.github/actions/publish-docker-image
name: Publish ${{ matrix.variant.img }}
with:
docker_tag: ${{ env.RELEASE_VERSION }}
rootDir: ${{ matrix.variant.dir }}/${{ matrix.variant.img }}
imagename: ${{ matrix.variant.img }}
docker_user: ${{ secrets.DOCKER_HUB_USER }}
docker_token: ${{ secrets.DOCKER_HUB_TOKEN }}
do_push: 'true'

# Release: Helm Charts
helm-release:
name: Publish new helm release
needs: [ prepare-hotfix-release, release-version ]
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
pages: write

if: needs.release-version.outputs.RELEASE_VERSION
steps:
- name: Export RELEASE_VERSION env
run: |
echo "RELEASE_VERSION=${{ needs.release-version.outputs.RELEASE_VERSION }}" >> $GITHUB_ENV
rafaelmag110 marked this conversation as resolved.
Show resolved Hide resolved
- 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 ${{ env.RELEASE_VERSION }}"

git push origin gh-pages

# Release: GitHub tag & release; Merges back releases into main; Starts a new development cycle;
rafaelmag110 marked this conversation as resolved.
Show resolved Hide resolved
github-release:
name: Publish new github release
needs: [ prepare-hotfix-release, release-version, maven-release, docker-release, helm-release ]
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
pages: write
pull-requests: write
if: needs.release-version.outputs.RELEASE_VERSION
rafaelmag110 marked this conversation as resolved.
Show resolved Hide resolved
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 "[email protected]"

# 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: false
removeArtifacts: true

publish-to-swaggerhub:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the job to publish the API spec to GH Pages is missing

Copy link
Contributor Author

@rafaelmag110 rafaelmag110 Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a copy of the existing publish-new-release workflow. That workflow did not contain the publication to GH pages so I left it out.
Publishing to GH pages started after 0.7.3 was released. Does it make sense to add the 0.7.4 specs to GH pages?

name: "Publish OpenAPI spec to Swaggerhub"
permissions:
contents: read
needs: [ prepare-hotfix-release, release-version ]
uses: ./.github/workflows/publish-swaggerhub.yaml
with:
downstream-version: ${{ needs.release-version.outputs.RELEASE_VERSION }}
secrets: inherit
Loading