From 9779d4f095d2c8ef55f9c17d8c966e41381dd0fb Mon Sep 17 00:00:00 2001 From: Chris Laprun Date: Thu, 15 Sep 2022 11:09:54 +0200 Subject: [PATCH 1/3] feat: add reusable release workflow and use it to also release BOM --- .github/workflows/release-project-in-dir.yml | 80 +++++++++++++ .github/workflows/release.yml | 116 ++++--------------- 2 files changed, 103 insertions(+), 93 deletions(-) create mode 100644 .github/workflows/release-project-in-dir.yml diff --git a/.github/workflows/release-project-in-dir.yml b/.github/workflows/release-project-in-dir.yml new file mode 100644 index 0000000000..d7b84b04e8 --- /dev/null +++ b/.github/workflows/release-project-in-dir.yml @@ -0,0 +1,80 @@ +name: Release project in specified directory + +on: + workflow_call: + inputs: + project-dir: + type: string + required: true + version-branch: + type: string + required: true + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout "${{inputs.version-branch}}" branch + uses: actions/checkout@v3 + with: + ref: "${{inputs.version-branch}}" + + - name: Set up Java and Maven + uses: actions/setup-java@v3 + with: + java-version: 11 + distribution: temurin + cache: 'maven' + + - name: Move to specified directory + working-directory: ${{inputs.project-dir}} + run: | + echo "Releasing from ${{inputs.project-dir}}" + shell: bash + + - name: Change version to release version + # Assume that RELEASE_VERSION will have form like: "v1.0.1". So we cut the "v" + run: mvn ${MAVEN_ARGS} versions:set -DnewVersion="${RELEASE_VERSION:1}" versions:commit + env: + RELEASE_VERSION: ${{ github.event.release.tag_name }} + + - name: Release Maven package + uses: samuelmeuli/action-maven-publish@v1 + with: + maven_profiles: "release" + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }} + nexus_username: ${{ secrets.OSSRH_USERNAME }} + nexus_password: ${{ secrets.OSSRH_TOKEN }} + + # This is separate job because there were issues with git after release step, was not able to commit changes. + update-working-version: + runs-on: ubuntu-latest + if: "success() && !contains(github.event.release.tag_name, 'RC')" # not sure we should keep this the RC part + steps: + - uses: actions/checkout@v3 + with: + ref: "${{inputs.version-branch}}" + + - name: Set up Java and Maven + uses: actions/setup-java@v3 + with: + java-version: 11 + distribution: temurin + cache: 'maven' + + - name: Change version to release version + run: | + mvn ${MAVEN_ARGS} versions:set -DnewVersion="${RELEASE_VERSION:1}" versions:commit + mvn ${MAVEN_ARGS} -q build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion}-SNAPSHOT versions:commit + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git commit -m "Set new SNAPSHOT version into pom files." -a + env: + RELEASE_VERSION: ${{ github.event.release.tag_name }} + + - name: Push changes to branch + uses: ad-m/github-push-action@master + with: + branch: "${{inputs.version-branch}}" + github_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7ae08ad476..0c16b4ec26 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,101 +8,31 @@ jobs: publish: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - if: ${{ startsWith(github.event.release.tag_name, 'v1.' ) }} - with: - ref: "v1" - - uses: actions/checkout@v3 - if: ${{ startsWith(github.event.release.tag_name, 'v2.') }} - with: - ref: "v2" - - uses: actions/checkout@v3 - if: ${{ startsWith(github.event.release.tag_name, 'v3.') }} - with: - ref: "v3" - - uses: actions/checkout@v3 - if: ${{ startsWith(github.event.release.tag_name, 'v4.') }} - - name: Set up Java and Maven - uses: actions/setup-java@v3 - with: - java-version: 11 - distribution: temurin - cache: 'maven' - - name: change version to release version - # Assume that RELEASE_VERSION will have form like: "v1.0.1". So we cut the "v" - run: ./mvnw ${MAVEN_ARGS} versions:set -DnewVersion="${RELEASE_VERSION:1}" versions:commit + - if: ${{ startsWith(github.event.release.tag_name, 'v1.' ) }} env: - RELEASE_VERSION: ${{ github.event.release.tag_name }} - - name: change version to release version for bom module - working-directory: ./operator-framework-bom - run: ./mvnw ${MAVEN_ARGS} versions:set -DnewVersion="${RELEASE_VERSION:1}" versions:commit + version-branch: "v1" + - if: ${{ startsWith(github.event.release.tag_name, 'v2.' ) }} env: - RELEASE_VERSION: ${{ github.event.release.tag_name }} - - name: Release Maven package - uses: samuelmeuli/action-maven-publish@v1 - with: - maven_profiles: "release" - gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} - gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }} - nexus_username: ${{ secrets.OSSRH_USERNAME }} - nexus_password: ${{ secrets.OSSRH_TOKEN }} - - - # This is separate job because there were issues with git after release step, was not able to commit changes. See history. - update-working-version: - runs-on: ubuntu-latest - if: "!contains(github.event.release.tag_name, 'RC')" - steps: - - uses: actions/checkout@v3 - if: ${{ startsWith(github.event.release.tag_name, 'v1.' ) }} - with: - ref: "v1" - - uses: actions/checkout@v3 - if: ${{ startsWith(github.event.release.tag_name, 'v2.') }} - with: - ref: "v2" - - uses: actions/checkout@v3 - if: ${{ startsWith(github.event.release.tag_name, 'v3.') }} - with: - ref: "v3" - - uses: actions/checkout@v3 - if: ${{ startsWith(github.event.release.tag_name, 'v4.') }} - - name: Set up Java and Maven - uses: actions/setup-java@v3 - with: - java-version: 11 - distribution: temurin - cache: 'maven' - - name: change version to release version - run: | - ./mvnw ${MAVEN_ARGS} versions:set -DnewVersion="${RELEASE_VERSION:1}" versions:commit - ./mvnw ${MAVEN_ARGS} -q build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion}-SNAPSHOT versions:commit - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - git commit -m "Set new SNAPSHOT version into pom files." -a + version-branch: "v2" + - if: ${{ startsWith(github.event.release.tag_name, 'v3.' ) }} env: - RELEASE_VERSION: ${{ github.event.release.tag_name }} - - name: Push changes v1 - uses: ad-m/github-push-action@master - if: ${{ startsWith(github.event.release.tag_name, 'v1.' ) }} - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - branch: "v1" - - name: Push changes v2 - uses: ad-m/github-push-action@master - if: ${{ startsWith(github.event.release.tag_name, 'v2.' ) }} - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - branch: "v2" - - name: Push changes v3 - uses: ad-m/github-push-action@master - if: ${{ startsWith(github.event.release.tag_name, 'v3.' ) }} - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - branch: "v3" - - name: Push changes v4 - uses: ad-m/github-push-action@master - if: ${{ startsWith(github.event.release.tag_name, 'v4.' ) }} + version-branch: "v3" + - if: ${{ startsWith(github.event.release.tag_name, 'v4.' ) }} + env: + version-branch: "main" + - name: Fail if version-branch is not set + if: "version-branch == ''" + run: exit 1 + + - name: Release SDK + uses: ./.github/workflows/release-project-in-dir.yml with: - github_token: ${{ secrets.GITHUB_TOKEN }} + version-branch: ${{version-branch}} + project-dir: '.' + - name: Release BOM + uses: ./.github/workflows/release-project-in-dir.yml + with: + version-branch: ${{version-branch}} + project-dir: './operator-framework-bom' + \ No newline at end of file From ff42ed970b58b7c5082a0612bdf54653540681a7 Mon Sep 17 00:00:00 2001 From: Chris Laprun Date: Thu, 15 Sep 2022 11:19:52 +0200 Subject: [PATCH 2/3] fix: add missing run steps --- .github/workflows/release.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0c16b4ec26..e0efcf324c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,20 +9,26 @@ jobs: runs-on: ubuntu-latest steps: - if: ${{ startsWith(github.event.release.tag_name, 'v1.' ) }} + run: echo "Matched ${{version-branch}} branch" env: version-branch: "v1" - if: ${{ startsWith(github.event.release.tag_name, 'v2.' ) }} + run: echo "Matched ${{version-branch}} branch" env: version-branch: "v2" - if: ${{ startsWith(github.event.release.tag_name, 'v3.' ) }} + run: echo "Matched ${{version-branch}} branch" env: version-branch: "v3" - if: ${{ startsWith(github.event.release.tag_name, 'v4.' ) }} + run: echo "Matched ${{version-branch}} branch" env: version-branch: "main" - name: Fail if version-branch is not set if: "version-branch == ''" - run: exit 1 + run: | + echo "Failed to find appropriate branch to release ${{github.event.release.tag_name}} from" + exit 1 - name: Release SDK uses: ./.github/workflows/release-project-in-dir.yml From bdc2b425771865a2014d259071af99ea11cddd21 Mon Sep 17 00:00:00 2001 From: Chris Laprun Date: Thu, 15 Sep 2022 13:50:09 +0200 Subject: [PATCH 3/3] chore: remove permanent effects to try workflow --- .github/workflows/release-project-in-dir.yml | 21 ++++++-------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release-project-in-dir.yml b/.github/workflows/release-project-in-dir.yml index d7b84b04e8..1f23951acf 100644 --- a/.github/workflows/release-project-in-dir.yml +++ b/.github/workflows/release-project-in-dir.yml @@ -38,15 +38,6 @@ jobs: env: RELEASE_VERSION: ${{ github.event.release.tag_name }} - - name: Release Maven package - uses: samuelmeuli/action-maven-publish@v1 - with: - maven_profiles: "release" - gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} - gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }} - nexus_username: ${{ secrets.OSSRH_USERNAME }} - nexus_password: ${{ secrets.OSSRH_TOKEN }} - # This is separate job because there were issues with git after release step, was not able to commit changes. update-working-version: runs-on: ubuntu-latest @@ -69,12 +60,12 @@ jobs: mvn ${MAVEN_ARGS} -q build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion}-SNAPSHOT versions:commit git config --local user.email "action@github.com" git config --local user.name "GitHub Action" - git commit -m "Set new SNAPSHOT version into pom files." -a +# git commit -m "Set new SNAPSHOT version into pom files." -a env: RELEASE_VERSION: ${{ github.event.release.tag_name }} - - name: Push changes to branch - uses: ad-m/github-push-action@master - with: - branch: "${{inputs.version-branch}}" - github_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file +# - name: Push changes to branch +# uses: ad-m/github-push-action@master +# with: +# branch: "${{inputs.version-branch}}" +# github_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file