Build Release triggered by tonghan-gsh 🎉 #24
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
# This workflow is used for release | |
# Triggers: | |
# 1. Manual trigger | |
# Jobs: | |
# 1. Check Code Format | |
# 2. PMD Scan | |
# 3. Calculate Version Number | |
# 4. Build Web Artifact | |
# 5. Build Client Artifact | |
# 6. Release (TODO) | |
# 7. Tag (TODO) | |
### | |
name: Build Release | |
run-name: Build Release triggered by ${{ github.actor }} 🎉 | |
on: | |
workflow_dispatch: | |
inputs: | |
rpm_release: | |
description: "Rpm release number" | |
required: false | |
default: '' | |
type: string | |
image_tag: | |
description: "Docker image tag" | |
required: false | |
default: '' | |
type: string | |
env: | |
ODC_CURRENT_BRANCH: ${{ github.ref_name }} | |
ODC_TARGET_BRANCH: ${{ github.base_ref }} | |
jobs: | |
check-format: | |
name: Check Code Format | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout workspace | |
uses: actions/checkout@v4 | |
- name: Setup JDK 8 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: "8" | |
distribution: "temurin" | |
cache: maven | |
- name: Check code format | |
run: mvn impsort:check formatter:validate | |
- name: Check license | |
run: mvn license:check | |
pmd-scan: | |
name: PMD Scan | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout workspace | |
uses: actions/checkout@v4 | |
- name: Setup JDK 8 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: "8" | |
distribution: "temurin" | |
cache: maven | |
- name: Build project | |
run: mvn clean install -Dmaven.test.skip=true | |
- name: Run PMD scan | |
run: mvn pmd:check | |
calculate-version: | |
name: Calculate Version Number | |
needs: [ check-format, pmd-scan ] | |
runs-on: ubuntu-latest | |
outputs: | |
odc_rpm_release_number: ${{ steps.calculate_version.outputs.odc_rpm_release_number }} | |
odc_docker_image_tag: ${{ steps.calculate_version.outputs.odc_docker_image_tag }} | |
steps: | |
- name: Checkout workspace | |
uses: actions/checkout@v4 | |
- name: Calculate version number | |
id: calculate_version | |
run: | | |
odc_rpm_release_number=$(date +%Y%m%d) | |
if [[ -n "${{ inputs.rpm_release }}" ]]; then odc_rpm_release_number="${{ inputs.rpm_release }}"; fi | |
echo "odc_rpm_release_number=${odc_rpm_release_number}" >> $GITHUB_OUTPUT | |
echo "odc_rpm_release_number=${odc_rpm_release_number}" | |
branch_match_regex="^(((dev/)?[0-9]\\.[0-9]\\.([0-9]{1,2}|x))|(release\\S*))$" | |
tag_prefix=`[[ "${{ env.ODC_CURRENT_BRANCH }}" =~ ${branch_match_regex} ]] && echo "" || echo "test-"` | |
odc_docker_image_tag="${tag_prefix}$(cat distribution/odc-server-VER.txt)" | |
if [[ -n "${{ inputs.image_tag }}" ]]; then odc_docker_image_tag="${{ inputs.image_tag }}"; fi | |
echo "odc_docker_image_tag=${odc_docker_image_tag}" >> $GITHUB_OUTPUT | |
echo "odc_docker_image_tag=${odc_docker_image_tag}" | |
build-web-arm64: | |
name: Build Web Artifact (ARM64) | |
needs: [ calculate-version ] | |
runs-on: ubuntu-latest | |
env: | |
odc_rpm_release_number: ${{ needs.calculate-version.outputs.odc_rpm_release_number }} | |
odc_docker_image_tag: ${{ needs.calculate-version.outputs.odc_docker_image_tag }} | |
steps: | |
- name: Checkout workspace | |
uses: actions/checkout@v4 | |
- name: Setup JDK 8 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: "8" | |
distribution: "temurin" | |
cache: maven | |
- name: action by obfarm++odc_build_arm++BUILD_DOCKER_IMAGE=1;BUILD_RPM=1;BUILD_RPM_VERSION=${{ inputs.rpm_release }};BUILD_DOCKER_TAG=${{ env.odc_docker_image_tag }} | |
uses: ./.github/obfarm/ | |
id: build-web-arm64 | |
with: | |
pipeline_id: ${{ github.run_id }} | |
project: ${{ github.repository }} | |
- name: Echo Build Result | |
run: | | |
main_version="$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | cut -d - -f 1)" | |
new_version="${main_version}-${odc_rpm_release_number}" | |
echo "::notice ::BUILD RPM DOWNLOAD URL https://farm-use-for-odc.obs.cn-east-3.myhuaweicloud.com/odc-rpm/$GITHUB_RUN_ID/odc-server-${new_version}.aarch64.rpm" | |
echo "::notice ::BUILD DOCKER IMAGE DOWNLOAD URL https://farm-use-for-odc.obs.cn-east-3.myhuaweicloud.com/odc-image/$GITHUB_RUN_ID/odc-${{ env.odc_docker_image_tag }}-arm64.tar.gz" | |
build-web-x86_64: | |
name: Build Web Artifact Release(AMD64) | |
needs: [ calculate-version ] | |
runs-on: ubuntu-latest | |
env: | |
odc_rpm_release_number: ${{ needs.calculate-version.outputs.odc_rpm_release_number }} | |
odc_docker_image_tag: ${{ needs.calculate-version.outputs.odc_docker_image_tag }} | |
steps: | |
- name: Checkout workspace | |
uses: actions/checkout@v4 | |
- name: action by obfarm++odc_build_amd++BUILD_DOCKER_IMAGE=1;BUILD_RPM=1;BUILD_RPM_VERSION=${{ inputs.rpm_release }};BUILD_DOCKER_TAG=${{ env.odc_docker_image_tag }} | |
uses: ./.github/obfarm/ | |
id: build-web-arm64 | |
with: | |
pipeline_id: ${{ github.run_id }} | |
project: ${{ github.repository }} | |
jobname: odc_build_amd | |
build-web-arm: | |
name: Build Web Artifact Release(ARM64) | |
needs: [ calculate-version ] | |
runs-on: ubuntu-latest | |
env: | |
odc_rpm_release_number: ${{ needs.calculate-version.outputs.odc_rpm_release_number }} | |
odc_docker_image_tag: ${{ needs.calculate-version.outputs.odc_docker_image_tag }} | |
steps: | |
- name: Checkout workspace | |
uses: actions/checkout@v4 | |
- name: action by obfarm++odc_build_arm++BUILD_DOCKER_IMAGE=1;BUILD_RPM=1;BUILD_RPM_VERSION=${{ inputs.rpm_release }};BUILD_DOCKER_TAG=${{ env.odc_docker_image_tag }} | |
uses: ./.github/obfarm/ | |
id: build-web-arm64 | |
with: | |
pipeline_id: ${{ github.run_id }} | |
project: ${{ github.repository }} | |
jobname: odc_build_arm | |
build-client: | |
name: Build Client Artifact | |
needs: [ calculate-version ] | |
runs-on: ubuntu-latest | |
env: | |
odc_rpm_release_number: ${{ needs.calculate-version.outputs.odc_rpm_release_number }} | |
odc_docker_image_tag: ${{ needs.calculate-version.outputs.odc_docker_image_tag }} | |
steps: | |
- name: Checkout workspace | |
uses: actions/checkout@v4 | |
- name: action by obfarm++odc_build_client | |
uses: ./.github/obfarm/ | |
id: build-client | |
with: | |
pipeline_id: ${{ github.run_id }} | |
project: ${{ github.repository }} | |
jobname: odc_build_client | |
release: | |
name: Release (Skip for now) | |
needs: [ build-client ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Release artifacts | |
run: echo "Skip for now 🤪" | |
tag: | |
name: Tag (Skip for now) | |
needs: [ release ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Tag release | |
run: echo "Skip for now 🤪" |