Skip to content

Commit 3231d7b

Browse files
committed
Make Slack notification step optional
* Simply some `if:` expressions * Document how to run release workflow * Add `on: schedule:` example * Add warning into docs about nested reusable workflow levels
1 parent b97ad92 commit 3231d7b

File tree

5 files changed

+48
-16
lines changed

5 files changed

+48
-16
lines changed

Diff for: .github/workflows/spring-artifactory-release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ on:
2020
required: false
2121
GRADLE_ENTERPRISE_SECRET_ACCESS_KEY:
2222
required: false
23+
SPRING_RELEASE_SLACK_WEBHOOK_URL:
24+
required: false
2325
GH_ACTIONS_REPO_TOKEN:
2426
required: true
2527
OSSRH_URL:
@@ -36,8 +38,6 @@ on:
3638
required: true
3739
JF_ARTIFACTORY_SPRING:
3840
required: true
39-
SPRING_RELEASE_SLACK_WEBHOOK_URL:
40-
required: true
4141

4242
env:
4343
GITHUB_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}

Diff for: .github/workflows/spring-finalize-release.yml

+12-11
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010

1111
secrets:
1212
SPRING_RELEASE_SLACK_WEBHOOK_URL:
13-
required: true
13+
required: false
1414
GH_ACTIONS_REPO_TOKEN:
1515
required: true
1616

@@ -52,13 +52,14 @@ jobs:
5252
gh api -X PATCH repos/$GITHUB_REPOSITORY/milestones/$MILESTONE_ID -f state='closed' --silent
5353
fi
5454
55-
# - name: Announce Release on Slack
56-
# uses: slackapi/[email protected]
57-
# env:
58-
# SLACK_WEBHOOK_URL: ${{ secrets.SPRING_RELEASE_SLACK_WEBHOOK_URL }}
59-
# SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
60-
# with:
61-
# payload: |
62-
# {
63-
# "text": "${{ github.event.repository.name }}-announcing `${{ env.MILESTONE }}`"
64-
# }
55+
- name: Announce Release on Slack
56+
uses: slackapi/[email protected]
57+
if: env.SLACK_WEBHOOK_URL
58+
env:
59+
SLACK_WEBHOOK_URL: ${{ secrets.SPRING_RELEASE_SLACK_WEBHOOK_URL }}
60+
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
61+
with:
62+
payload: |
63+
{
64+
"text": "${{ github.event.repository.name }}-announcing `${{ env.MILESTONE }}`"
65+
}

Diff for: .github/workflows/spring-stage-release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
5656
staging-with-gradle:
5757
needs: maven-or-gradle
58-
if: ${{ needs.maven-or-gradle.outputs.isMaven == 'false' }}
58+
if: needs.maven-or-gradle.outputs.isMaven == 'false'
5959
uses: ./.github/workflows/spring-artifactory-gradle-release-staging.yml
6060
with:
6161
releaseVersion: ${{ inputs.releaseVersion }}
@@ -65,7 +65,7 @@ jobs:
6565

6666
staging-with-maven:
6767
needs: maven-or-gradle
68-
if: ${{ needs.maven-or-gradle.outputs.isMaven == 'true' }}
68+
if: needs.maven-or-gradle.outputs.isMaven == 'true'
6969
uses: ./.github/workflows/spring-artifactory-maven-release-staging.yml
7070
with:
7171
releaseVersion: ${{ inputs.releaseVersion }}

Diff for: README.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ GPG_PRIVATE_KEY
2020
```
2121

2222
The Gradle Enterprise secrets are optional: not used by Maven and Gradle project might not be enrolled for the service.
23+
The `SPRING_RELEASE_SLACK_WEBHOOK_URL` secret is also optional: probably you don't want to notify Slack about your release.
2324

2425
The mentioned secrets must be passed explicitly since these reusable workflows might be in different GitHub org than target project.
2526

@@ -71,7 +72,7 @@ This job stages released artifacts using JFrog CLI into `libs-staging-local` rep
7172
- When verification is successful, next job promotes release from staging either to `libs-milestone-local` or `libs-release-local`(and Maven Central) according to the releasing version schema
7273
- Then [spring-finalize-release.yml](.github/workflows/spring-finalize-release.yml) job is executed, which generates release notes using [Spring Changelog Generator](https://github.com/spring-io/github-changelog-generator) excluding repository admins from `Contributors` section.
7374
The `gh release create` command is performed on a tag for just released version.
74-
And in the end the milestone is closed and specific Slack channel is notified about release.
75+
And in the end the milestone is closed and specific Slack channel is notified about release (if `SPRING_RELEASE_SLACK_WEBHOOK_URL` secret is present in the repository).
7576

7677
#### Example of Release caller workflow:
7778
https://github.com/artembilan/spring-messaging-build-tools/blob/decee2963c926c34f1f52bf373a3bc1dc09f1724/samples/release.yml#L1-L25
@@ -82,6 +83,15 @@ The `buildToolArgs` parameter for this job means extra build tool arguments.
8283
For example, the mentioned `dist` value is a Gradle task in the project.
8384
Can be any Maven goal or other command line arguments.
8485

86+
In the end you just need to go to the `Actions` tab on your project, press `Run workflow` on your release workflow and choose a branch from drop-down list to release currently scheduled Milestone against.
87+
Such a release workflow can also be scheduled (`cron`, fo example) against branches matrix:
88+
89+
90+
> **Warning**
91+
> The [spring-artifactory-release.yml](.github/workflows/spring-artifactory-release.yml) already uses 3 of 4 levels of nested reusable workflows.
92+
> Where the caller workflow is the last one.
93+
> Therefore don't try to reuse your caller workflow.
94+
8595
## Verify Staged Artifacts
8696

8797
The `verify-staged` job expects an optional `verifyStagedWorkflow` input (the `verify-staged-artifacts.yml`, by default) workflow supplied from the target project.
@@ -96,3 +106,5 @@ https://github.com/artembilan/spring-messaging-build-tools/blob/dbd138bf504abec5
96106
Gradle projects must not manage `com.jfrog.artifactory` plugin anymore: the `jf gradlec` command sets up this plugin and respective tasks into a project using JFrog specific Gradle init script.
97107
In addition, the [spring-artifactory-gradle-snapshot.yml](.github/workflows/spring-artifactory-gradle-snapshot.yml) and [spring-artifactory-gradle-release-staging.yml](.github/workflows/spring-artifactory-gradle-release-staging.yml) add `spring-project-init.gradle` script to provide an `artifactory` plugin settings for artifacts publications.
98108
This script also adds a `nextDevelopmentVersion` task which is used when release has been staged and job is ready to push `Next development version` commit.
109+
110+
See more information in the [Reusing Workflows](https://docs.github.com/en/actions/using-workflows/reusing-workflows).

Diff for: samples/schedule-releases.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Release Scheduler
2+
on:
3+
schedule:
4+
- cron: '15 15 * * MON' # Every Monday at 3:15pm UTC
5+
6+
jobs:
7+
dispatch_scheduled_releases:
8+
strategy:
9+
matrix:
10+
# List of active maintenance branches.
11+
branch: [ main, 6.1.x, 6.0.x, 5.8.x ]
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Dispatch
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
19+
run: gh workflow run release.yml -r ${{ matrix.branch }}

0 commit comments

Comments
 (0)