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

feat: add semantic-release based CI pipelines #136

Merged
merged 4 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
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
176 changes: 137 additions & 39 deletions .github/workflows/flow-deploy-release-artifact.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,29 @@

name: "Deploy Release Artifact"
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+-?*"
workflow_dispatch:
inputs:
dry-run-enabled:
description: "Perform Dry Run"
type: boolean
required: false
default: false
java-distribution:
description: "Java JDK Distribution:"
type: string
required: false
default: "temurin"
java-version:
description: "Java JDK Version:"
type: string
required: false
default: "17.0.7"
gradle-version:
description: "Gradle Version:"
type: string
required: false
default: "wrapper"

env:
REGISTRY: ghcr.io

Expand All @@ -27,46 +47,53 @@ defaults:
shell: bash

jobs:
prepare-tag-release:
name: Release / Tag / Prepare
prepare-release:
name: Release / Prepare
runs-on: [self-hosted, Linux, medium, ephemeral]
outputs:
version: ${{ steps.tag.outputs.version }}
prerelease: ${{ steps.tag.outputs.prerelease }}
steps:
- name: Install Semantic Version Tools
run: |
echo "::group::Download SemVer Binary"
sudo curl -L -o /usr/local/bin/semver https://raw.githubusercontent.com/fsaintjacques/semver-tool/master/src/semver
echo "::endgroup::"
echo "::group::Change SemVer Binary Permissions"
sudo chmod -v +x /usr/local/bin/semver
echo "::endgroup::"
echo "::group::Show SemVer Binary Version Info"
semver --version
echo "::endgroup::"

- name: Extract Tag Version
id: tag
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install Semantic Release
run: |
RELEASE_VERSION="$(semver get release "${{ github.ref_name }}")"
PRERELEASE_VERSION="$(semver get prerel "${{ github.ref_name }}")"
npm install -g semantic-release @semantic-release/git @semantic-release/exec gradle-semantic-release-plugin
npm install -g conventional-changelog-conventionalcommits @commitlint/cli @commitlint/config-conventional
npm install -g marked-mangle marked-gfm-heading-id

FINAL_VERSION="${RELEASE_VERSION}"
PRERELEASE_FLAG="false"
[[ -n "${PRERELEASE_VERSION}" ]] && FINAL_VERSION="${RELEASE_VERSION}-${PRERELEASE_VERSION}"
[[ -n "${PRERELEASE_VERSION}" ]] && PRERELEASE_FLAG="true"
- name: Calculate Next Version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_USER_NAME }}
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
GIT_COMMITTER_NAME: ${{ secrets.GIT_USER_NAME }}
GIT_COMMITTER_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
run: npx semantic-release --dry-run

echo "version=${FINAL_VERSION}" >>"${GITHUB_OUTPUT}"
echo "prerelease=${PRERELEASE_FLAG}" >>"${GITHUB_OUTPUT}"
- name: Extract Version
id: tag
run: echo "version=$(cat VERSION | tr -d '[:space:]')" >> ${GITHUB_OUTPUT}

release-tag:
name: Release / Tag
publish-maven-central:
name: Publish
uses: ./.github/workflows/zxc-release-maven-central.yaml
needs:
- prepare-tag-release
- prepare-release
with:
new-version: ${{ needs.prepare-tag-release.outputs.version }}
custom-job-label: Maven Central
new-version: ${{ needs.prepare-release.outputs.version }}
dry-run-enabled: ${{ github.event.inputs.dry-run-enabled == 'true' }}
java-distribution: ${{ github.event.inputs.java-distribution || '17.0.7' }}
java-version: ${{ github.event.inputs.java-version || 'temurin' }}
gradle-version: ${{ github.event.inputs.gradle-version || 'wrapper' }}
secrets:
gpg-key-contents: ${{ secrets.GPG_KEY_CONTENTS }}
gpg-key-passphrase: ${{ secrets.GPG_KEY_PASSPHRASE }}
Expand All @@ -75,11 +102,11 @@ jobs:
ossrh-user-name: ${{ secrets.OSSRH_USER_NAME }}
ossrh-user-password: ${{ secrets.OSSRH_USER_PASSWORD }}

docker-image-publish:
name: "Publish / Docker Image"
publish-docker-image:
name: Publish / Docker Image
runs-on: [self-hosted, Linux, medium, ephemeral]
needs:
- prepare-tag-release
- prepare-release
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -104,8 +131,8 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64, linux/arm64
push: true
tags: ${{ env.REGISTRY }}/${{ github.repository }}/ubi8-init-dind:${{needs.prepare-tag-release.outputs.version}}
push: ${{ github.event.inputs.dry-run-enabled != 'true' }}
tags: ghcr.io/${{ github.repository }}/ubi8-init-dind:${{ needs.prepare-release.outputs.version }}

- name: Build Docker Image (ubi8-init-java17)
uses: docker/build-push-action@v4
Expand All @@ -114,5 +141,76 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64, linux/arm64
push: true
tags: ${{ env.REGISTRY }}/${{ github.repository }}/ubi8-init-java17:${{needs.prepare-tag-release.outputs.version}}
push: ${{ github.event.inputs.dry-run-enabled != 'true' }}
tags: ghcr.io/${{ github.repository }}/ubi8-init-java17:${{ needs.prepare-release.outputs.version }}

create-github-release:
name: Github / Release
runs-on: [self-hosted, Linux, medium, ephemeral]
needs:
- publish-maven-central
- publish-docker-image
if: ${{ github.event.inputs.dry-run-enabled != 'true' && !cancelled() && !failure() }}
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
token: ${{ secrets.GH_ACCESS_TOKEN }}
fetch-depth: 0

- name: Install GnuPG Tools
run: |
if ! command -v gpg2 >/dev/null 2>&1; then
echo "::group::Updating APT Repository Indices"
sudo apt update
echo "::endgroup::"
echo "::group::Installing GnuPG Tools"
sudo apt install -y gnupg2
echo "::endgroup::"
fi

- name: Import GPG key
id: gpg_key
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_KEY_CONTENTS }}
passphrase: ${{ secrets.GPG_KEY_PASSPHRASE }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
git_tag_gpgsign: false

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: ${{ inputs.java-distribution }}
java-version: ${{ inputs.java-version }}

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: wrapper
gradle-home-cache-includes: |
caches
notifications
dependency-check-data

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install Semantic Release
run: |
npm install -g semantic-release @semantic-release/git @semantic-release/exec gradle-semantic-release-plugin
npm install -g conventional-changelog-conventionalcommits @commitlint/cli @commitlint/config-conventional
npm install -g marked-mangle marked-gfm-heading-id

- name: Publish Semantic Release
env:
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_USER_NAME }}
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
GIT_COMMITTER_NAME: ${{ secrets.GIT_USER_NAME }}
GIT_COMMITTER_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
run: npx semantic-release
17 changes: 1 addition & 16 deletions .github/workflows/zxc-release-maven-central.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ jobs:
echo "::endgroup::"
fi

- name: Install Commitizen Tools
run: sudo pip3 install -U commitizen

- name: Import GPG key
id: gpg_key
uses: crazy-max/ghaction-import-gpg@v5
Expand Down Expand Up @@ -130,19 +127,7 @@ jobs:
uses: gradle/gradle-build-action@v2
with:
gradle-version: ${{ inputs.gradle-version }}
arguments: "versionAsSpecified --scan -PnewVersion=${{ inputs.new-version }}"

- name: Create Release Notes
id: create-release-notes
run: |
echo "RELEASE_NOTES<<EOF" >> "$GITHUB_OUTPUT"
cz changelog --dry-run "$(cz version --project)" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"

- name: Display Release Notes
run: |
echo "Release Notes:"
echo "${{ steps.create-release-notes.outputs.RELEASE_NOTES }}"
arguments: versionAsSpecified --scan -PnewVersion=${{ inputs.new-version }}

- name: Version Report
uses: gradle/gradle-build-action@v2
Expand Down
56 changes: 56 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"plugins": [
"@semantic-release/commit-analyzer",
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits"
}
],
"@semantic-release/git",
"@semantic-release/github"
],
"verifyRelease": [
[
"@semantic-release/exec",
{ "cmd": "echo ${nextRelease.version} > VERSION" }
]
],
"prepare": [
[
"@semantic-release/exec",
{ "cmd": "./gradlew versionAsSpecified --scan -PnewVersion=${nextRelease.version}" }
],
[
"@semantic-release/git",
{
"assets": [
"gradle.properties"
]
}
]
],
"branches":[
{
"name": "main"
},
{
"name": "release/+([0-9])?(.{+([0-9]),x}).x"
},
{
"name": "alpha/*",
"prerelease": "alpha",
"channel": "alpha"
},
{
"name": "beta/*",
"prerelease": "beta",
"channel": "beta"
},
{
"name": "rc/*",
"prerelease": "rc",
"channel": "rc"
}
]
}
5 changes: 2 additions & 3 deletions fullstack-helm-client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ tasks.withType<ProcessResources> { dependsOn(tasks.withType<HelmArtifactTask>())

dependencies {
// Bill of Materials
implementation(enforcedPlatform(project(":fullstack-bom")))
implementation(platform(project(":fullstack-bom")))
javaModuleDependencies {
testImplementation(gav("org.junit.jupiter.api"))
testImplementation(gav("org.junit.jupiter.params"))
testImplementation(gav("org.assertj.core"))
testImplementation(gav("org.mockito"))
testImplementation(gav("org.mockito.junit.jupiter"))
}
}

Expand Down
3 changes: 2 additions & 1 deletion fullstack-helm-client/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
opens com.hedera.fullstack.helm.client.model.install to
com.fasterxml.jackson.databind;

requires com.hedera.fullstack.base.api;
requires com.fasterxml.jackson.databind;
requires transitive com.hedera.fullstack.base.api;
requires transitive com.fasterxml.jackson.annotation;
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ end-to-end and full stack tests against the Hedera network software. Designed wi
purpose built for the Hedera community and open-source contributors.

# Version for all subprojects
version=0.1.0-SNAPSHOT
version=0.1.2

# Set the default Group ID
group=com.hedera.fullstack
Expand Down