Skip to content

feat: add reusable release workflow and use it to also release BOM #1466

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

Merged
merged 3 commits into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
71 changes: 71 additions & 0 deletions .github/workflows/release-project-in-dir.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
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 }}

# 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 }}
122 changes: 29 additions & 93 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,101 +8,37 @@ 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.' ) }}
run: echo "Matched ${{version-branch}} branch"
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.' ) }}
run: echo "Matched ${{version-branch}} branch"
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.' ) }}
run: echo "Matched ${{version-branch}} branch"
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.' ) }}
run: echo "Matched ${{version-branch}} branch"
env:
version-branch: "main"
- name: Fail if version-branch is not set
if: "version-branch == ''"
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
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'