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

Allow for overriding how trigger release announcement step gets version information #23

Merged
merged 2 commits into from
Aug 30, 2020
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
2 changes: 1 addition & 1 deletion .github/workflows/release-notes-reminder.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Release Notes Reminder

on:
pull_request:
pull_request_target:
types: [labeled]

jobs:
Expand Down
36 changes: 36 additions & 0 deletions .release-notes/23.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Allow for overriding how trigger release announcement step gets version information

Adds an optional environment variable VERSION that can be set to an explicit value when using the trigger-release-announcement step instead of getting the version from GITHUB_REF.

The VERSION environment variable allows for a wider variety of ways to trigger the step. Prior to this change, the step would not work if it wasn't triggered by pushing a tag. With this change, you can now use it other workflows.

[ponyc](https://github.com/ponylang/ponyc) will use it to be triggered once assets are uploaded to Cloudsmith doing something slightly more complicated than the following simplified example:


```yaml
name: Handle external events

on: repository_dispatch

jobs:
trigger-release-announcement:
if: |
github.event.action == 'cloudsmith-package-synchronised' &&
github.event.client_payload.data.repository == 'releases' &&
github.event.client_payload.data.name == 'ponyc-x86-64-unknown-linux-musl.tar.gz'

name: Trigger release announcement
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Trigger
uses: ponylang/[email protected]
with:
step: trigger-release-announcement
git_user_name: "Ponylang Main Bot"
git_user_email: "[email protected]"
env:
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
VERSION: ${{ github.event.client_payload.data.version }}
```
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ jobs:
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
```

trigger-release-announcement, by default, will extract the version being released from the GITHUB_REF environment variable. For this default action to work, trigger-release-announcement must be kicked off by a tag being pushed. If you set up the step to be triggered in any other fashion it will not work unless you supply the version yourself. You can supply the version by providing an optional environment variable `VERSION` set to the version being released.

## announce-a-release

Announces a release after artifacts have been built:
Expand Down
20 changes: 16 additions & 4 deletions scripts/trigger-release-announcement.bash
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,22 @@ set -o nounset

PUSH_TO="https://${RELEASE_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"

# Extract version from tag reference
# Tag ref version: "refs/tags/1.0.0"
# Version: "1.0.0"
VERSION="${GITHUB_REF/refs\/tags\//}"
if [[ -z "${VERSION}" ]]; then
echo -e "\e[34mOptional VERSION environment variable found. Using it.\e[0m"
else
# Extract version from tag reference
# Tag ref version: "refs/tags/1.0.0"
# Version: "1.0.0"
# Note, this will only work if the action was kicked off by the push of tag.
# Anything else will result in the ref being something like
# "refs/heads/master" and the pushed tag will be something 'incorrect' like
# "announce-refs/heads/master".
# If you are using this action and it isn't triggered by a tag push, you must
# use the optional VERSION environment variable instead of falling back to
# the default behavior of extracting the version from GITHUB_REF.
echo -e "\e[34mExtracting version from GITHUB_REF.\e[0m"
VERSION="${GITHUB_REF/refs\/tags\//}"
fi

# tag for announcement
echo -e "\e[34mTagging to kick off release announcement\e[0m"
Expand Down