Skip to content

Deploy Release Artifact #86

Deploy Release Artifact

Deploy Release Artifact #86

##
# 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:
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
defaults:
run:
shell: bash
jobs:
prepare-release:
name: Release / Prepare
runs-on: [self-hosted, Linux, medium, ephemeral]
outputs:
version: ${{ steps.tag.outputs.version }}
steps:
- name: Checkout Code
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
with:
node-version: 18
- name: Install Semantic Release
run: |
npm install -g semantic-release@21.0.7 @semantic-release/git@10.0.1 @semantic-release/exec@6.0.3 gradle-semantic-release-plugin@1.7.6
npm install -g conventional-changelog-conventionalcommits@6.1.0 @commitlint/cli@17.6.6 @commitlint/config-conventional@17.6.6
npm install -g marked-mangle@1.0.1 marked-gfm-heading-id@3.0.4 semantic-release-conventional-commits@3.0.0
- 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
- name: Extract Version
id: tag
run: |
cat VERSION
[[ ! -f VERSION ]] && echo "VERSION file is not found" && exit 1 # error on missing VERSION file
echo "version=$(cat VERSION | tr -d '[:space:]')" >> ${GITHUB_OUTPUT}
publish-maven-central:
name: Publish
uses: ./.github/workflows/zxc-release-maven-central.yaml
needs:
- prepare-release
with:
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 }}
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 }}
publish-docker-image:
name: Publish / Docker Image
runs-on: [self-hosted, Linux, medium, ephemeral]
needs:
- prepare-release
steps:
- name: Checkout repository
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- name: Login to GitHub Container Registry
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Qemu
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
- name: Build Docker Image (ubi8-init-dind)
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: docker/ubi8-init-dind
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64, linux/arm64
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@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: docker/ubi8-init-java17
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64, linux/arm64
push: ${{ github.event.inputs.dry-run-enabled != 'true' }}
tags: ghcr.io/${{ github.repository }}/ubi8-init-java17:${{ needs.prepare-release.outputs.version }}
- name: Build Docker Image (kubectl-bats)
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: docker/kubectl-bats
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64, linux/arm64
push: ${{ github.event.inputs.dry-run-enabled != 'true' }}
tags: ghcr.io/${{ github.repository }}/kubectl-bats:${{ needs.prepare-release.outputs.version }}
publish-npm-packages:
name: Publish / NPM Packages
runs-on: [self-hosted, Linux, medium, ephemeral]
needs:
- prepare-release
steps:
- name: Checkout repository
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- name: Install Node
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
with:
node-version: 18
- name: Publish NPM Package
working-directory: "fullstack-network-manager"
env:
NPM_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm ci
npm i replace-json-property && ./node_modules/replace-json-property/bin/replace-json-property.bin.js package.json version ${{ needs.prepare-release.outputs.version }} && cat package.json | grep 'version'
npm publish ${{ github.event.inputs.dry-run-enabled && '--dry-run' || '' }}
create-github-release:
name: Github / Release
runs-on: [self-hosted, Linux, medium, ephemeral]
needs:
- publish-maven-central
- publish-docker-image
- publish-npm-packages
if: ${{ github.event.inputs.dry-run-enabled != 'true' && !cancelled() && !failure() }}
steps:
- name: Checkout Code
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
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@82a020f1f7f605c65dd2449b392a52c3fcfef7ef # v6.0.0
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@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
with:
distribution: ${{ inputs.java-distribution }}
java-version: ${{ inputs.java-version }}
- name: Setup Gradle
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0
with:
gradle-version: wrapper
gradle-home-cache-includes: |
caches
notifications
dependency-check-data
- name: Setup Node
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
with:
node-version: 18
- name: Install Semantic Release
run: |
npm install -g semantic-release@21.0.7 @semantic-release/git@10.0.1 @semantic-release/exec@6.0.3 gradle-semantic-release-plugin@1.7.6
npm install -g conventional-changelog-conventionalcommits@6.1.0 @commitlint/cli@17.6.6 @commitlint/config-conventional@17.6.6
npm install -g marked-mangle@1.0.1 marked-gfm-heading-id@3.0.4 semantic-release-conventional-commits@3.0.0
- 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