From f39c079dc2558af0c9b409f181b1881643662b95 Mon Sep 17 00:00:00 2001 From: Lun Wang Date: Tue, 10 Oct 2023 11:07:20 +0800 Subject: [PATCH] Fix GitHub workflows --- .github/workflows/build-and-test.yaml | 9 ++++ .github/workflows/build.yaml | 11 ----- .github/workflows/check_version/action.yaml | 39 --------------- .github/workflows/create-release-branch.yaml | 39 --------------- .../workflows/download_gpg_key/action.yaml | 30 ------------ .github/workflows/publish-major.yaml | 17 +++++++ .github/workflows/publish-minor.yaml | 17 +++++++ .github/workflows/publish-patch.yaml | 17 +++++++ .github/workflows/publish-snapshot.yaml | 33 +++++++------ .github/workflows/release-major-minor.yaml | 47 ------------------- .github/workflows/release-patch.yaml | 47 ------------------- .github/workflows/release.yaml | 16 ------- 12 files changed, 76 insertions(+), 246 deletions(-) create mode 100644 .github/workflows/build-and-test.yaml delete mode 100644 .github/workflows/build.yaml delete mode 100644 .github/workflows/check_version/action.yaml delete mode 100644 .github/workflows/create-release-branch.yaml delete mode 100644 .github/workflows/download_gpg_key/action.yaml create mode 100644 .github/workflows/publish-major.yaml create mode 100644 .github/workflows/publish-minor.yaml create mode 100644 .github/workflows/publish-patch.yaml delete mode 100644 .github/workflows/release-major-minor.yaml delete mode 100644 .github/workflows/release-patch.yaml delete mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml new file mode 100644 index 0000000..6f6f7a5 --- /dev/null +++ b/.github/workflows/build-and-test.yaml @@ -0,0 +1,9 @@ +name: Build and Test +on: [pull_request, push, workflow_dispatch] + +jobs: + build: + uses: IABTechLab/uid2-shared-actions/.github/workflows/shared-build-and-test.yaml@main + with: + java_version: "11" + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml deleted file mode 100644 index 5db5f0c..0000000 --- a/.github/workflows/build.yaml +++ /dev/null @@ -1,11 +0,0 @@ -name: Build -on: [push] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Build - run: mvn -B clean compile test diff --git a/.github/workflows/check_version/action.yaml b/.github/workflows/check_version/action.yaml deleted file mode 100644 index bf09b14..0000000 --- a/.github/workflows/check_version/action.yaml +++ /dev/null @@ -1,39 +0,0 @@ -name: Check Version -# This workflow checks that the version in the commit is valid. -# Valid meaning: -# - Not Already Released -# - Has -SNAPSHOT for now released workflows -inputs: - needs_snapshot: - description: 'If set to true, this version needs a -SNAPSHOT' - required: 'true' - type: string -outputs: - version: - description: 'The Version of the package' - value: ${{ steps.version.outputs.jar_version }} -runs: - using: "composite" - - steps: - - name: Get Jar Version - id: version - shell: bash - run: echo "::set-output name=jar_version::$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" - - name: Check if Version has Snapshot - if: ${{ inputs.needs_snapshot == 'true' }} - shell: bash - run: grep -q "\-SNAPSHOT" <<< "${{ steps.version.outputs.jar_version }}" - - name: Check if Version has no Snapshot - if: ${{ inputs.needs_snapshot == 'false' }} - shell: bash - run: grep -vq "\-SNAPSHOT" <<< "${{ steps.version.outputs.jar_version }}" - - name: Check if Version is released - shell: bash - run: | - export VERSION=${{ steps.version.outputs.jar_version }} - if [[ $VERSION == *"-SNAPSHOT"* ]]; then - export VERSION=$(echo $VERSION | awk '{ print substr( $0, 1, length($0)-9 ) }') - fi - mvn dependency:get -Dartifact=$(mvn help:evaluate -Dexpression=project.name -q -DforceStdout):$VERSION || exit 0 - exit 1 diff --git a/.github/workflows/create-release-branch.yaml b/.github/workflows/create-release-branch.yaml deleted file mode 100644 index 586376b..0000000 --- a/.github/workflows/create-release-branch.yaml +++ /dev/null @@ -1,39 +0,0 @@ -name: Create Release Branch -on: - workflow_dispatch: - inputs: - version: - description: 'The version tag to create the branch from' - type: string - required: true - workflow_call: - inputs: - version: - description: 'The version tag to create the branch from' - type: string - required: true - -jobs: - create_branch: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Get Short Version - id: version - run: | - echo "::set-output name=short_version::$(echo ${{ github.event.inputs.version }} | rev | cut -c3- | rev)" - - name: Checkout Branch from tag - run: | - git fetch --tags - git checkout -b release-${{ steps.version.outputs.short_version }} ${{ github.event.inputs.version }} - - name: Bump Version - run: mvn versions:set -DnextSnapshot - - name: Commit Pom.xml - uses: EndBug/add-and-commit@v9 - with: - add: 'pom.xml' - author_name: Release Workflow - author_email: unifiedid-admin+release@thetradedesk.com - push: '--set-upstream origin release-${{ steps.version.outputs.short_version }}' - message: 'release-branch-${{ github.event.inputs.version }}' diff --git a/.github/workflows/download_gpg_key/action.yaml b/.github/workflows/download_gpg_key/action.yaml deleted file mode 100644 index e1c3c0d..0000000 --- a/.github/workflows/download_gpg_key/action.yaml +++ /dev/null @@ -1,30 +0,0 @@ -name: Setup Dependancies -inputs: - key: - descriptions: 'The Key to be imported' - required: true - type: string - -runs: - using: "composite" - steps: - - name: Setup settings.xml - shell: bash - run: | - mkdir ~/.m2 - echo "" >> ~/.m2/settings.xml - echo " " >> ~/.m2/settings.xml - echo " " >> ~/.m2/settings.xml - echo " \${repo.id}" >> ~/.m2/settings.xml - echo " \${repo.login}" >> ~/.m2/settings.xml - echo " \${repo.pwd}" >> ~/.m2/settings.xml - echo " " >> ~/.m2/settings.xml - echo " " >> ~/.m2/settings.xml - echo "" >> ~/.m2/settings.xml - - name: Import GPG key - shell: bash - run: | - echo -n "$GPG_SIGNING_KEY" | base64 --decode > private.key - gpg --batch --import private.key - env: - GPG_SIGNING_KEY: ${{ inputs.key }} diff --git a/.github/workflows/publish-major.yaml b/.github/workflows/publish-major.yaml new file mode 100644 index 0000000..3b4bfec --- /dev/null +++ b/.github/workflows/publish-major.yaml @@ -0,0 +1,17 @@ +name: Publish Major Package +on: + workflow_dispatch: + inputs: + publish_to_maven: + description: 'True to publish the artifacts to maven repository, false to skip the step' + default: true + required: false + type: boolean +jobs: + build-publish-package: + uses: IABTechLab/uid2-shared-actions/.github/workflows/shared-java-publish-versioned-package.yaml@main + with: + release_type: 'Major' + publish_to_maven: ${{ inputs.publish_to_maven }} + java_version: "11" + secrets: inherit diff --git a/.github/workflows/publish-minor.yaml b/.github/workflows/publish-minor.yaml new file mode 100644 index 0000000..73fed0c --- /dev/null +++ b/.github/workflows/publish-minor.yaml @@ -0,0 +1,17 @@ +name: Publish Minor Package +on: + workflow_dispatch: + inputs: + publish_to_maven: + description: 'True to publish the artifacts to maven repository, false to skip the step' + default: true + required: false + type: boolean +jobs: + build-publish-package: + uses: IABTechLab/uid2-shared-actions/.github/workflows/shared-java-publish-versioned-package.yaml@main + with: + release_type: 'Minor' + publish_to_maven: ${{ inputs.publish_to_maven }} + java_version: "11" + secrets: inherit diff --git a/.github/workflows/publish-patch.yaml b/.github/workflows/publish-patch.yaml new file mode 100644 index 0000000..433c289 --- /dev/null +++ b/.github/workflows/publish-patch.yaml @@ -0,0 +1,17 @@ +name: Publish Patch Package +on: + workflow_dispatch: + inputs: + publish_to_maven: + description: 'True to publish the artifacts to maven repository, false to skip the step' + default: true + required: false + type: boolean +jobs: + build-publish-package: + uses: IABTechLab/uid2-shared-actions/.github/workflows/shared-java-publish-versioned-package.yaml@main + with: + release_type: 'Patch' + publish_to_maven: ${{ inputs.publish_to_maven }} + java_version: "11" + secrets: inherit diff --git a/.github/workflows/publish-snapshot.yaml b/.github/workflows/publish-snapshot.yaml index 6539f14..3f2b68d 100644 --- a/.github/workflows/publish-snapshot.yaml +++ b/.github/workflows/publish-snapshot.yaml @@ -1,18 +1,17 @@ -name: Publish Snapshot -on: workflow_dispatch - +name: Publish Snapshot Package +on: + workflow_dispatch: + inputs: + publish_to_maven: + description: 'True to publish the artifacts to maven repository, false to skip the step' + default: true + required: false + type: boolean jobs: - publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: ./.github/workflows/download_gpg_key - with: - key: ${{ secrets.GPG_KEY }} - - name: Check Version is snapshot - id: check_verion - uses: ./.github/workflows/check_version - with: - needs_snapshot: 'true' - - name: Deploy Snapshot - run: mvn -B -Drepo.id=ossrh -Drepo.login="{{ secrets.SONATYPE_REPO_ACCOUNT }}" -Drepo.pwd="${{ secrets.SONATYPE_REPO_PASSWORD }}" -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" clean deploy + build-publish-package: + uses: IABTechLab/uid2-shared-actions/.github/workflows/shared-java-publish-versioned-package.yaml@main + with: + release_type: 'Snapshot' + publish_to_maven: ${{ inputs.publish_to_maven }} + java_version: "11" + secrets: inherit diff --git a/.github/workflows/release-major-minor.yaml b/.github/workflows/release-major-minor.yaml deleted file mode 100644 index 27089bf..0000000 --- a/.github/workflows/release-major-minor.yaml +++ /dev/null @@ -1,47 +0,0 @@ -name: Release Major/Minor -on: [workflow_dispatch] - -jobs: - release: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: ./.github/workflows/download_gpg_key - with: - key: ${{ secrets.GPG_KEY }} - - name: Check Version before any work - uses: ./.github/workflows/check_version - with: - needs_snapshot: 'true' - - name: Remove Snapshot - run: mvn -B versions:set -DremoveSnapshot - - name: Check Version snapshot removed - id: check_version - uses: ./.github/workflows/check_version - with: - needs_snapshot: 'false' - - name: Commit Pom.xml - uses: EndBug/add-and-commit@v9 - with: - add: 'pom.xml' - author_name: Release Workflow - author_email: unifiedid-admin+release@thetradedesk.com - message: 'release-${{ steps.check_version.outputs.version }}' - tag: '${{ steps.check_version.outputs.version }}' - - name: Publish - run: mvn -B -Drepo.id=ossrh -Drepo.login="{{ secrets.SONATYPE_REPO_ACCOUNT }}" -Drepo.pwd="${{ secrets.SONATYPE_REPO_PASSWORD }}" -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" clean deploy - #" - - name: Bump Version - run: mvn build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.0-SNAPSHOT versions:commit - - name: Check Version Bump Was Successful - id: check_version_after - uses: ./.github/workflows/check_version - with: - needs_snapshot: 'true' - - name: Commit Pom.xml - uses: EndBug/add-and-commit@v9 - with: - add: 'pom.xml' - author_name: Release Workflow - author_email: unifiedid-admin+release@thetradedesk.com - message: 'Increment ${{ steps.check_version.outputs.version }} to ${{ steps.check_version_after.outputs.version }}' diff --git a/.github/workflows/release-patch.yaml b/.github/workflows/release-patch.yaml deleted file mode 100644 index 481fd1b..0000000 --- a/.github/workflows/release-patch.yaml +++ /dev/null @@ -1,47 +0,0 @@ -name: Release Patch -on: workflow_dispatch - -jobs: - release: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: ./.github/workflows/download_gpg_key - with: - key: ${{ secrets.GPG_KEY }} - - name: Check Version before any work - uses: ./.github/workflows/check_version - with: - needs_snapshot: 'true' - - name: Remove Snapshot - run: mvn -B versions:set -DremoveSnapshot - - name: Check Version snapshot removed - id: check_version - uses: ./.github/workflows/check_version - with: - needs_snapshot: 'false' - - name: Commit Pom.xml - uses: EndBug/add-and-commit@v9 - with: - add: 'pom.xml' - author_name: Release Workflow - author_email: unifiedid-admin+release@thetradedesk.com - message: 'release-${{ steps.check_version.outputs.version }}' - tag: '${{ steps.check_version.outputs.version }}' - - name: Publish - run: mvn -B -Drepo.id=ossrh -Drepo.login="{{ secrets.SONATYPE_REPO_ACCOUNT }}" -Drepo.pwd="${{ secrets.SONATYPE_REPO_PASSWORD }}" -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" clean deploy - #" - - name: Bump Version - run: mvn versions:set -DnextSnapshot - - name: Check Version Bump Was Successful - id: check_version_after - uses: ./.github/workflows/check_version - with: - needs_snapshot: 'true' - - name: Commit Pom.xml - uses: EndBug/add-and-commit@v9 - with: - add: 'pom.xml' - author_name: Release Workflow - author_email: unifiedid-admin+release@thetradedesk.com - message: 'Increment ${{ steps.check_version.outputs.version }} to ${{ steps.check_version_after.outputs.version }}' diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index aa35319..0000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,16 +0,0 @@ -name: Release -on: workflow_dispatch - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - uses: ./.github/workflows/download_gpg_key - with: - key: ${{ secrets.GPG_KEY }} - - name: Remove Snapshot - run: mvn versions:set -DremoveSnapshot - - name: Deploy Snapshot - run: mvn -Drepo.id=ossrh -Drepo.login="{{ secrets.SONATYPE_REPO_ACCOUNT }}" -Drepo.pwd="${{ secrets.SONATYPE_REPO_PASSWORD }}" -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" clean deploy