Skip to content

Commit

Permalink
build: revisit release workflows (#1180)
Browse files Browse the repository at this point in the history
  • Loading branch information
chillleader authored Oct 5, 2023
1 parent 25dfbd4 commit 26cd031
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 39 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/CREATE_RELEASE_BRANCH.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Create release branch

on:
workflow_dispatch:
inputs:
version:
description: 'Semantic version number of release: ^[0-9]+.[0-9]+.[0-9]+(-[a-zA-Z0-9.-]+){0,1}$'
required: true
setVersionOnMain:
description: 'Set the new snapshot version on main branch?'
type: boolean
required: true
default: true

jobs:
create-release-branch:
name: Create release branch
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}

- name: Prepare Java and Maven settings
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: 'maven'

- name: Configure git user
run: |
# https://github.com/actions/checkout/issues/13#issuecomment-724415212
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Create branch and set release version
run: |
git checkout -b release/${{ github.event.inputs.version }}
mvn -B versions:set -DnewVersion=${RELEASE_VERSION} -DgenerateBackupPoms=false -f parent
git add parent/pom.xml
git commit -am "ci: set next release version"
git push --follow-tags
env:
RELEASE_VERSION: ${{ github.event.inputs.version }}

- name: Set snapshot version on main branch
if: ${{ github.event.inputs.setVersionOnMain == 'true' }}
run: |
git checkout main
mvn -B versions:set -DnewVersion=${SNAPSHOT_VERSION} -DgenerateBackupPoms=false -f parent
git add parent/pom.xml
git commit -am "ci: set next snapshot version"
git push
File renamed without changes.
60 changes: 23 additions & 37 deletions .github/workflows/RELEASE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,8 @@ name: Release a new version
run-name: Release a new version ${{ inputs.version }}

on:
workflow_dispatch:
inputs:
version:
description: 'Semantic version number of release: ^[0-9]+.[0-9]+.[0-9]+(-[a-zA-Z0-9.-]+){0,1}$'
required: true
nextVersion:
description: 'Semantic version number to use as next SNAPSHOT version: ^[0-9]+.[0-9]+.[0-9]+(-[a-zA-Z0-9.-]+){0,1}$'
required: true
branch:
description: 'Git branch to be used in the release'
default: 'main'
release:
types: [ published ]

jobs:
build-and-push:
Expand All @@ -21,7 +12,7 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
ref: ${{ github.event.release.tag_name }}
fetch-depth: 0

- name: Import Secrets
Expand Down Expand Up @@ -85,7 +76,9 @@ jobs:
- name: Check if new version implies pre-release
id: check_prerelease
run: |
if [[ ${{ github.event.inputs.version }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
if [[ ${{github.event.release.prerelease}} == "true" ]]; then
PRE_RELEASE=true
elif [[ ${{ github.event.release.tag_name }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
PRE_RELEASE=false
else
PRE_RELEASE=true
Expand All @@ -96,9 +89,9 @@ jobs:
id: get_previous_tag
run: |
if [[ ${{steps.check_prerelease.outputs.isPreRelease}} == "true" ]]; then
TAG_NAME=$(git --no-pager tag --sort=-creatordate | head -1)
TAG_NAME=$(git --no-pager tag --sort=-creatordate | head -2 | tail -1)
else
TAG_NAME=$(git --no-pager tag --sort=-creatordate | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | head -1)
TAG_NAME=$(git --no-pager tag --sort=-creatordate | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | head -2 | tail -1)
fi
echo "previousTag: $TAG_NAME"
echo "previousTag=${TAG_NAME}" >> $GITHUB_OUTPUT
Expand All @@ -108,7 +101,7 @@ jobs:
- name: Set Connectors release version
run: mvn -B versions:set -DnewVersion=${RELEASE_VERSION} -DgenerateBackupPoms=false -f parent
env:
RELEASE_VERSION: ${{ github.event.inputs.version }}
RELEASE_VERSION: ${{ github.event.release.tag_name }}

- name: Deploy artifacts to Artifactory and Maven Central
run: mvn -B compile generate-sources source:jar javadoc:jar deploy -PcheckFormat -Psonatype-oss-release
Expand All @@ -124,15 +117,7 @@ jobs:
git commit -am "ci: release version ${RELEASE_VERSION}"
git tag -a ${RELEASE_VERSION} -m "ci: release version ${RELEASE_VERSION}"
env:
RELEASE_VERSION: ${{ github.event.inputs.version }}

- name: Set next development patch version
run: |
mvn -B versions:set -DnewVersion=${NEXT_VERSION}-SNAPSHOT -DgenerateBackupPoms=false -f parent
git commit -am "ci: set next development version"
git push --follow-tags
env:
NEXT_VERSION: ${{ github.event.inputs.nextVersion }}
RELEASE_VERSION: ${{ github.event.release.tag_name }}

- name: Generate sbom reports
run: |
Expand All @@ -154,30 +139,30 @@ jobs:

# Build & push bundle docker images (with version tag)

- name: Build and Push Docker Image tag ${{ github.event.inputs.version }} - connector-runtime
- name: Build and Push Docker Image tag ${{ github.event.release.tag_name }} - connector-runtime
uses: docker/build-push-action@v5
with:
context: connector-runtime/connector-runtime-application/
push: ${{ github.ref == 'refs/heads/main' }}
tags: camunda/connectors:${{ github.event.inputs.version }}
tags: camunda/connectors:${{ github.event.release.tag_name }}
platforms: linux/amd64,linux/arm64
provenance: false

- name: Build and Push Docker Image tag ${{ github.event.inputs.version }} - bundle-default
- name: Build and Push Docker Image tag ${{ github.event.release.tag_name }} - bundle-default
uses: docker/build-push-action@v5
with:
context: bundle/default-bundle/
push: ${{ github.ref == 'refs/heads/main' }}
tags: camunda/connectors-bundle:${{ github.event.inputs.version }}
tags: camunda/connectors-bundle:${{ github.event.release.tag_name }}
platforms: linux/amd64,linux/arm64
provenance: false

- name: Build and Push Docker Image tag ${{ github.event.inputs.version }} - bundle-saas
- name: Build and Push Docker Image tag ${{ github.event.release.tag_name }} - bundle-saas
uses: docker/build-push-action@v5
with:
context: bundle/camunda-saas-bundle/
push: ${{ github.ref == 'refs/heads/main' }}
tags: camunda/connectors-bundle-saas:${{ github.event.inputs.version }}
tags: camunda/connectors-bundle-saas:${{ github.event.release.tag_name }}
platforms: linux/amd64,linux/arm64
provenance: false

Expand Down Expand Up @@ -238,19 +223,19 @@ jobs:
readme_file: bundle/README.md
short_description: 'Camunda out-of-the-box Connectors Bundle for SaaS'

# Create GitHub release
# Update GitHub release

- name: Bundle element templates
run: bash bundle/bundle-templates.sh ${RELEASE_VERSION}
env:
RELEASE_VERSION: ${{ github.event.inputs.version }}
RELEASE_VERSION: ${{ github.event.release.tag_name }}

- name: Build Changelog
id: changelog
uses: Requarks/changelog-action@v1
with:
token: ${{ github.token }}
fromTag: ${{ github.event.inputs.version }}
fromTag: ${{ github.event.release.tag_name }}
toTag: ${{ steps.get_previous_tag.outputs.previousTag }}
writeToFile: false
excludeTypes: build,docs,other,style,ci
Expand All @@ -260,9 +245,10 @@ jobs:
with:
prerelease: ${{ steps.check_prerelease.outputs.isPreRelease }}
body: ${{ steps.changelog.outputs.changes }}
tag_name: ${{ github.event.inputs.version }}
name: ${{ github.event.release.name }}
tag_name: ${{ github.event.release.tag_name }}
files: |
bundle/default-bundle/target/connectors-bundle-sbom.json
bundle/default-bundle/target/connectors-bundle-sbom.xml
connectors-bundle-templates-${{ github.event.inputs.version }}.tar.gz
connectors-bundle-templates-${{ github.event.inputs.version }}.zip
connectors-bundle-templates-${{ github.event.release.tag_name }}.tar.gz
connectors-bundle-templates-${{ github.event.release.tag_name }}.zip
File renamed without changes.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,5 @@ mvn clean package

## Build a release

Trigger the [release action](https://github.com/camunda/connector-sdk/actions/workflows/RELEASE.yml) manually with the version `x.y.z` you want to release.
You can choose the branch to execute the action on as described in the [GitHub documentation](https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow).
1. For minor releases (x.y.0), create a new branch `release/x.y` from `main` in advance and rebase it onto `main` from time to time. This can be done using the `CREATE_RELEASE_BRANCH` workflow.
2. To trigger the release, publish a new GitHub release and name the tag according to the version you want to release (e.g. `1.0.0`). This will trigger a GitHub workflow that builds and publishes the release artifacts, generates a changelog and bundles the element templates into an archive.

0 comments on commit 26cd031

Please sign in to comment.