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: GitHub Action for artifact deployment #103

Merged
merged 80 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
8224bed
first version of artifact deployment cloned from platform
jeromy-cannon Jun 13, 2023
7df6425
uncomment the job label
jeromy-cannon Jun 13, 2023
e2b73f0
pull_request to enable
jeromy-cannon Jun 13, 2023
6e55cfa
don't need working directory override
jeromy-cannon Jun 13, 2023
4f76021
Validate Workflow Inputs
jeromy-cannon Jun 13, 2023
3fc888b
echo vars
jeromy-cannon Jun 13, 2023
a5a50a8
set new version temporarily
jeromy-cannon Jun 13, 2023
aa488fe
fixed yaml
jeromy-cannon Jun 13, 2023
5eec0ab
fixed yaml
jeromy-cannon Jun 13, 2023
b472241
fixed yaml
jeromy-cannon Jun 13, 2023
0f29d21
fixed yaml
jeromy-cannon Jun 13, 2023
08dff40
echo build
jeromy-cannon Jun 13, 2023
c9f6e6c
Import GPG key
jeromy-cannon Jun 13, 2023
e167e53
java & gradle
jeromy-cannon Jun 13, 2023
9e4a8d7
fix yaml
jeromy-cannon Jun 13, 2023
e4e2d92
spotlessApply
jeromy-cannon Jun 13, 2023
9ae3fbe
gpg pass?
jeromy-cannon Jun 13, 2023
2e05690
exclude gpg for now
jeromy-cannon Jun 13, 2023
d2bc0cf
defaults
jeromy-cannon Jun 13, 2023
0d9a2f8
Apply Version Number Update (Explicit)
jeromy-cannon Jun 13, 2023
0e11ab0
remove build directory
jeromy-cannon Jun 13, 2023
4a41ca9
gradle commands
jeromy-cannon Jun 13, 2023
17837df
added gradle dependencies
jeromy-cannon Jun 13, 2023
bbf323c
added gradle dependencies
jeromy-cannon Jun 13, 2023
f2b8fc9
remove build dir
jeromy-cannon Jun 13, 2023
a5673e0
Gradle Deploy
jeromy-cannon Jun 13, 2023
85e28b1
license and team update
jeromy-cannon Jun 13, 2023
25ed25e
update version for all gradle.properties to 0.0.1
jeromy-cannon Jun 13, 2023
d686d82
add -i for gradle to help troubleshoot
jeromy-cannon Jun 14, 2023
90812d7
log jars
jeromy-cannon Jun 14, 2023
4945bb2
Revert "update version for all gradle.properties to 0.0.1"
jeromy-cannon Jun 14, 2023
8f6a5ac
comment out gradle deploy
jeromy-cannon Jun 14, 2023
93448fd
enabled secrets and removed sections not needed
jeromy-cannon Jun 15, 2023
aa42f97
removed jar find
jeromy-cannon Jun 16, 2023
f41a022
test secret
jeromy-cannon Jun 16, 2023
cfd457e
try workflow_dispatch
jeromy-cannon Jun 16, 2023
af8fa09
updates based on conversations with Nathan
jeromy-cannon Jun 17, 2023
891d230
remove unused access-token
jeromy-cannon Jun 17, 2023
af42543
force version for testing
jeromy-cannon Jun 17, 2023
1f15190
updates to fix invalid workflow
jeromy-cannon Jun 17, 2023
b0f41f7
updates to fix invalid workflow
jeromy-cannon Jun 17, 2023
f56967f
spotlessApply
jeromy-cannon Jun 17, 2023
548f8e3
add maven-publish kotlin script
jeromy-cannon Jun 17, 2023
dd2beac
moved maven-publish into bom
jeromy-cannon Jun 20, 2023
89ad029
switched from "java" to "javaPlatform"
jeromy-cannon Jun 20, 2023
7567b64
Revert "switched from "java" to "javaPlatform""
jeromy-cannon Jun 20, 2023
7924659
Revert "moved maven-publish into bom"
jeromy-cannon Jun 20, 2023
e56228f
switch to id("") syntax
jeromy-cannon Jun 20, 2023
e2550fa
subprojects with java-platform approach
jeromy-cannon Jun 21, 2023
2b63bf4
maven-publish to all projects except for examples and base
jeromy-cannon Jun 21, 2023
aff2e72
working with alert-api
jeromy-cannon Jun 21, 2023
285b3a7
add back full implementation
jeromy-cannon Jun 21, 2023
9856b6e
remove maven-publish from helm client
jeromy-cannon Jun 21, 2023
6643516
comment out commit version changes
jeromy-cannon Jun 21, 2023
b2db75d
delete commit version changes
jeromy-cannon Jun 21, 2023
2e0426d
check for python installations
jeromy-cannon Jun 21, 2023
43abae2
feat: initialize commitizen
jeromy-cannon Jun 21, 2023
0fef24e
bump: version 0.0.1 → 0.1.0
jeromy-cannon Jun 21, 2023
a364a24
feat: this is a test of a commitizen commit message
jeromy-cannon Jun 21, 2023
97bb807
ci: add commitizen and set version to 0.1.0
jeromy-cannon Jun 21, 2023
347e325
add logic to set commitizen version manually
jeromy-cannon Jun 22, 2023
7b3e524
add message to bypass error with git tag lightweight not working
jeromy-cannon Jun 22, 2023
c2beb7c
use github env for storing release notes
jeromy-cannon Jun 22, 2023
48ec93f
working version with Nathan
jeromy-cannon Jun 23, 2023
9c7ba8d
snapshots
jeromy-cannon Jun 23, 2023
123a301
added v prefix to version in tag format for commitizen
jeromy-cannon Jun 23, 2023
fa0f80b
don't publish modules that don't have any code, yet
jeromy-cannon Jun 23, 2023
a79fb0c
publish to github output instead of github env
jeromy-cannon Jun 23, 2023
46f12d7
exclude helm-client from BOM manifest
jeromy-cannon Jun 23, 2023
8ce69c6
feat: added another release notes echo
jeromy-cannon Jun 23, 2023
c787e42
fix: added outputs section to reusable workflow
jeromy-cannon Jun 23, 2023
94af773
fix: added value element on release notes output
jeromy-cannon Jun 23, 2023
8b7a733
fix: corrected outputs to line up correctly
jeromy-cannon Jun 23, 2023
010856a
break intentionally
jeromy-cannon Jun 23, 2023
044b324
fix break
jeromy-cannon Jun 23, 2023
65b73d1
removed PR entries
jeromy-cannon Jun 23, 2023
d6f5238
remove unused dry-run-enabled from main workflow
jeromy-cannon Jun 23, 2023
3eecfc8
final version for testing with tag
jeromy-cannon Jun 23, 2023
4376049
prep for PR review
jeromy-cannon Jun 23, 2023
900d899
updated email address
jeromy-cannon Jun 23, 2023
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
6 changes: 6 additions & 0 deletions .cz.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[tool.commitizen]
name = "cz_conventional_commits"
tag_format = "v$version"
version_scheme = "semver"
version = "0.1.0-SNAPSHOT"
major_version_zero = true
75 changes: 75 additions & 0 deletions .github/workflows/flow-deploy-release-artifact.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
##
# Copyright (C) 2023 Hedera Hashgraph, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://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.
##

name: "Deploy Release Artifact"
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+-?*"

defaults:
run:
shell: bash

jobs:
prepare-tag-release:
name: Release / Tag / 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
run: |
RELEASE_VERSION="$(semver get release "${{ github.ref_name }}")"
PRERELEASE_VERSION="$(semver get prerel "${{ github.ref_name }}")"

FINAL_VERSION="${RELEASE_VERSION}"
PRERELEASE_FLAG="false"
[[ -n "${PRERELEASE_VERSION}" ]] && FINAL_VERSION="${RELEASE_VERSION}-${PRERELEASE_VERSION}"
[[ -n "${PRERELEASE_VERSION}" ]] && PRERELEASE_FLAG="true"

echo "version=${FINAL_VERSION}" >>"${GITHUB_OUTPUT}"
echo "prerelease=${PRERELEASE_FLAG}" >>"${GITHUB_OUTPUT}"

release-tag:
name: Release / Tag
uses: ./.github/workflows/zxc-release-maven-central.yaml
needs:
- prepare-tag-release
with:
new-version: ${{ needs.prepare-tag-release.outputs.version }}
secrets:
# access-token: ${{ secrets.GITHUB_TOKEN }}
gpg-key-contents: ${{ secrets.GPG_KEY_CONTENTS }}
gpg-key-passphrase: ${{ secrets.GPG_KEY_PASSPHRASE }}
git-user-name: ${{ secrets.GIT_USER_NAME }}
git-user-email: ${{ secrets.GIT_USER_EMAIL }}
ossrh-user-name: ${{ secrets.OSSRH_USER_NAME }}
ossrh-user-password: ${{ secrets.OSSRH_USER_PASSWORD }}
178 changes: 178 additions & 0 deletions .github/workflows/zxc-release-maven-central.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
##
# Copyright (C) 2022-2023 Hedera Hashgraph, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://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.
##

name: "ZXC: Release Maven Central"
on:
workflow_call:
inputs:
new-version:
description: "New Release Version (ie. 0.30.0):"
type: string
required: true
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.3"
gradle-version:
description: "Gradle Version:"
type: string
required: false
default: "wrapper"
custom-job-label:
description: "Custom Job Label:"
type: string
required: false
default: "Release"
outputs:
release-notes:
description: "Release notes for the new release"
value: ${{ jobs.release.outputs.notes }}
secrets:
gpg-key-contents:
required: false
gpg-key-passphrase:
required: false
git-user-name:
required: false
git-user-email:
required: false
ossrh-user-name:
required: true
ossrh-user-password:
required: true

defaults:
run:
shell: bash

permissions:
id-token: write
contents: write

jobs:
release:
name: ${{ inputs.custom-job-label || 'Release' }}
runs-on: [self-hosted, Linux, medium, ephemeral]
outputs:
notes: ${{ steps.create-release-notes.outputs.RELEASE_NOTES }}
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
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: Install Commitizen Tools
run: sudo pip3 install -U commitizen

- name: Import GPG key
id: gpg_key
uses: crazy-max/ghaction-import-gpg@v5
if: ${{ inputs.dry-run-enabled != true && !cancelled() && !failure() }}
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: true

- 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: ${{ inputs.gradle-version }}
gradle-home-cache-includes: |
caches
notifications
dependency-check-data

- name: Apply Version Number Update (Explicit)
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 }}"

- name: Version Report
uses: gradle/gradle-build-action@v2
with:
gradle-version: ${{ inputs.gradle-version }}
arguments: githubVersionSummary --scan

- name: Gradle Assemble
id: gradle-build
uses: gradle/gradle-build-action@v2
if: ${{ inputs.dry-run-enabled != true && !cancelled() && !failure() }}
with:
gradle-version: ${{ inputs.gradle-version }}
arguments: assemble --scan

- name: Gradle JavaDoc
id: gradle-javadoc
uses: gradle/gradle-build-action@v2
if: ${{ steps.gradle-build.conclusion == 'success' && !cancelled() && !failure() }}
with:
gradle-version: ${{ inputs.gradle-version }}
arguments: javadoc --scan

- name: Gradle Deploy
uses: gradle/gradle-build-action@v2
if: ${{ inputs.dry-run-enabled != true && !cancelled() && !failure() }}
env:
OSSRH_USERNAME: ${{ secrets.ossrh-user-name }}
OSSRH_PASSWORD: ${{ secrets.ossrh-user-password }}
with:
gradle-version: ${{ inputs.gradle-version }}
# always run with --no-parallel to avoid sonatype maven publish issues which result in invalid publications
arguments: releaseMavenCentral --scan -PpublishSigningEnabled=true --no-parallel
89 changes: 89 additions & 0 deletions buildSrc/src/main/kotlin/Utils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Copyright (C) 2023 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://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.
*/
import net.swiftzer.semver.SemVer
import org.gradle.api.Project
import java.io.File
import java.io.OutputStream
import java.io.PrintStream

class Utils {
companion object {
@JvmStatic
fun updateVersion(project: Project, newVersion: SemVer) {
val gradlePropFile = File(project.projectDir, "gradle.properties")
updateStringInFile(gradlePropFile, "version=", "version=${newVersion}")
}

@JvmStatic
fun updateCommitizenVersion(project: Project, newVersion: SemVer) {
val czFile = File(project.projectDir, ".cz.toml")
updateStringInFile(czFile, "version =", "version = \"${newVersion}\"")
}

private fun updateStringInFile(file: File, startsWith: String, newString: String) {
var lines: List<String> = mutableListOf()

if (file.exists()) {
lines = file.readLines(Charsets.UTF_8)
}

val finalLines: List<String>

if (lines.isNotEmpty()) {
finalLines = lines.map {
if (it.trimStart().startsWith(startsWith)) {
newString
} else {
it
}
}
} else {
finalLines = listOf(newString)
}

file.bufferedWriter(Charsets.UTF_8).use {
val writer = it
finalLines.forEach {
writer.write(it)
writer.newLine()
}
writer.flush()
}
}

@JvmStatic
fun generateProjectVersionReport(rootProject: Project, ostream: OutputStream) {
val writer = PrintStream(ostream, false, Charsets.UTF_8)

ostream.use {
writer.use {
// Writer headers
writer.println("### Deployed Version Information")
writer.println()
writer.println("| Artifact Name | Version Number |")
writer.println("| --- | --- |")

// Write table rows
rootProject.childProjects.values.onEach {
writer.printf("| %s | %s |\n", it.name, it.version.toString())
}
writer.flush()
ostream.flush()
}
}
}
}
}
Loading