Skip to content
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

fix: release process fix #38

Merged
merged 11 commits into from
Jul 2, 2024
163 changes: 29 additions & 134 deletions .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,74 +9,47 @@ concurrency:
cancel-in-progress: true

jobs:
pr-validation:
name: Pull Request Validation
runs-on: ubuntu-22.04
permissions:
contents: read
pull-requests: write
vars:
name: Variables
runs-on: ubuntu-latest
outputs:
version: ${{ steps.changelog.outputs.version }}
semver: ${{ steps.semver.outputs.tag }}
steps:
# steps.semver.outputs.tag => needs.vars.outputs.semver
- uses: actions/checkout@v4

- name: Pull request size and stability labels
uses: actions/labeler@v5
continue-on-error: true
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"

- name: Conventional Label
uses: bcoe/conventional-release-labels@v1
continue-on-error: true
with:
token: ${{ secrets.GITHUB_TOKEN }}
ignored_types: '["chore","pr"]'
type_labels: '{"feat": "feature", "fix": "fix", "bug": "fix", "doc": "documentation", "ci": "ci", "chore": "chore", "breaking": "breaking", "BREAKING CHANGE": "breaking"}'

- name: Checkout branch
uses: actions/checkout@v4
with:
ref: refs/heads/${{ github.head_ref }}

ref: refs/heads/${{ github.event.repository.default_branch }}
- name: Conventional Changelog Update
continue-on-error: true
uses: TriPSs/conventional-changelog-action@v5
id: changelog
uses: TriPSs/[email protected]
id: semver
with:
github-token: ${{ github.token }}
output-file: "CHANGELOG.md"
skip-version-file: "true"
skip-commit: "true"
git-push: "false"
git-branch: refs/heads/${{ github.head_ref }}
skip-on-empty: "false"
git-push: 'false'
skip-commit: 'true'
skip-on-empty: 'false'
skip-version-file: 'true'

- name: Checkout pr
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Comment PR
continue-on-error: true
uses: thollander/actions-comment-pull-request@v2
if: ${{ steps.changelog.outputs.skipped == 'false' }}
with:
message: |
# Current changelog

${{ steps.changelog.outputs.clean_changelog }}
comment_tag: "# Current changelog"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
echo "semver=${{ steps.semver.outputs.tag }}"

pr-validation:
name: Pull Request Validation
runs-on: ubuntu-22.04
needs: [vars]
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4

- name: Removing old core
uses: paulushcgcj/[email protected]
continue-on-error: true
with:
token: ${{ secrets.PAT }}
type: maven
name: ca.bc.gov.nrs-commons.forest-client-core
version: ${{ steps.changelog.outputs.version }}.PR${{ github.event.number }}
version: ${{ needs.vars.outputs.semver }}.PR${{ github.event.number }}
user: ${{ github.repository_owner }}

- name: Removing old spring
Expand All @@ -86,50 +59,13 @@ jobs:
token: ${{ secrets.PAT }}
type: maven
name: ca.bc.gov.nrs-commons.forest-client-spring
version: ${{ steps.changelog.outputs.version }}.PR${{ github.event.number }}
version: ${{ needs.vars.outputs.semver }}.PR${{ github.event.number }}
user: ${{ github.repository_owner }}

pr-greeting:
name: PR Greeting
runs-on: ubuntu-22.04
needs: pr-validation
permissions:
pull-requests: write
steps:
- name: PR Greeting
uses: bcgov-nr/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
add_markdown: |
---
Thanks for the PR!


```
<dependency>
<groupId>ca.bc.gov.nrs-commons</groupId>
<artifactId>forest-client-core</artifactId>
<version>${{ needs.pr-validation.outputs.version }}.PR${{ github.event.number }}</version>
</dependency>
```

```
<dependency>
<groupId>ca.bc.gov.nrs-commons</groupId>
<artifactId>forest-client-spring</artifactId>
<version>${{ needs.pr-validation.outputs.version }}.PR${{ github.event.number }}</version>
</dependency>
```

Once merged, the code will be promoted and handed off to the following workflow run.
[Main Merge Workflow](https://github.com/${{ github.repository }}/actions/workflows/merge-main.yml)

build-certextractor:
name: Builds Cert Extractor
runs-on: ubuntu-22.04
needs:
- pr-validation
- pr-greeting
needs: [pr-validation]
steps:
- uses: actions/checkout@v4

Expand All @@ -145,9 +81,7 @@ jobs:
build-core:
name: Build Core
runs-on: ubuntu-22.04
needs:
- pr-validation
- pr-greeting
needs: [vars, pr-validation]
permissions:
packages: write
steps:
Expand All @@ -171,46 +105,7 @@ jobs:
uses: paulushcgcj/[email protected]
with:
dir: core
app-version: ${{ needs.pr-validation.outputs.version }}.PR${{ github.event.number }}
extra-params: -DskipTests -Dtests.skip=true
add-sources: true
add-javadoc: true
env:
GITHUB_TOKEN: ${{ github.token }}

build-spring:
name: Build Spring
runs-on: ubuntu-22.04
needs:
- pr-validation
- pr-greeting
- build-core
permissions:
packages: write
steps:
- uses: actions/checkout@v4

- uses: bcgov-nr/[email protected]
name: Spring Coverage
with:
commands: |
mvn versions:use-dep-version -DdepVersion=${{ needs.pr-validation.outputs.version }}.PR${{ github.event.number }} -Dincludes=ca.bc.gov.nrs-commons:forest-client-core -DforceVersion=true --file pom.xml
mvn -B verify -P all-tests checkstyle:checkstyle -Dcheckstyle.skip=false --file pom.xml
dir: spring
java-cache: maven
java-distribution: temurin
java-version: "17"
sonar_args: >
-Dsonar.organization=bcgov-sonarcloud
-Dsonar.projectKey=bcgov_nr-forest-client-commons
sonar_token: ${{ secrets.SONAR_TOKEN_COMMONS }}

- name: Publish Spring
uses: paulushcgcj/[email protected]
with:
commands: mvn versions:use-dep-version -DdepVersion=${{ needs.pr-validation.outputs.version }}.PR${{ github.event.number }} -Dincludes=ca.bc.gov.nrs-commons:forest-client-core -DforceVersion=true --file pom.xml
dir: spring
app-version: ${{ needs.pr-validation.outputs.version }}.PR${{ github.event.number }}
app-version: ${{ needs.vars.outputs.semver }}.PR${{ github.event.number }}
extra-params: -DskipTests -Dtests.skip=true
add-sources: true
add-javadoc: true
Expand Down
109 changes: 109 additions & 0 deletions .github/workflows/pr-validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: PR Validate

on:
pull_request:
types: [edited, opened, synchronize, reopened]

concurrency:
group: ${{ github.workflow }}-edit-${{ github.event.number }}
cancel-in-progress: true

jobs:
vars:
name: Variables
runs-on: ubuntu-latest
outputs:
semver: ${{ steps.semver.outputs.tag }}
steps:
# steps.semver.outputs.tag => needs.vars.outputs.semver
- uses: actions/checkout@v4
with:
ref: refs/heads/${{ github.event.repository.default_branch }}
- name: Conventional Changelog Update
uses: TriPSs/[email protected]
id: semver
with:
git-branch: refs/heads/${{ github.head_ref }}
git-push: 'false'
skip-commit: 'true'
skip-on-empty: 'false'
skip-version-file: 'true'

- run: |
echo "semver=${{ steps.semver.outputs.tag }}"

validate:
name: Validate PR
needs: [vars]
uses: bcgov/quickstart-openshift-helpers/.github/workflows/[email protected]
with:
markdown_links: |
Any successful releases will be available as the following dependencyes:
```
<dependency>
<groupId>ca.bc.gov.nrs-commons</groupId>
<artifactId>forest-client-core</artifactId>
<version>${{ needs.vars.outputs.semver }}.PR${{ github.event.number }}</version>
</dependency>
```

```
<dependency>
<groupId>ca.bc.gov.nrs-commons</groupId>
<artifactId>forest-client-spring</artifactId>
<version>${{ needs.vars.outputs.semver }}.PR${{ github.event.number }}</version>
</dependency>
```

Once merged, the code will be promoted and handed off to the following workflow run.
[Main Merge Workflow](https://github.com/${{ github.repository }}/actions/workflows/merge-main.yml)

changelog:
name: Pull Request Validation
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4

- name: Checkout branch
uses: actions/checkout@v4
with:
ref: refs/heads/${{ github.head_ref }}

- name: Conventional Changelog Update
id: changelog
continue-on-error: true
uses: TriPSs/conventional-changelog-action@v5
with:
github-token: ${{ github.token }}
output-file: "CHANGELOG.md"
skip-version-file: "true"
skip-commit: "true"
git-push: "false"
git-branch: refs/heads/${{ github.head_ref }}

- name: Checkout pr
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Comment PR
continue-on-error: true
uses: thollander/actions-comment-pull-request@v2
if: ${{ steps.changelog.outputs.skipped == 'false' }}
with:
message: |
# Current changelog

${{ steps.changelog.outputs.clean_changelog }}
comment_tag: "# Current changelog"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

results:
name: Validate Results
needs: [changelog, validate]
runs-on: ubuntu-22.04
steps:
- run: echo "Workflow completed successfully!"
Loading