-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea60e98
commit 1cddd38
Showing
6 changed files
with
307 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{{ .header }} 🏷 | ||
|
||
Tag: `{{ .tag }}` | ||
|
||
{{ .body }} | ||
|
||
{{ .footer }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Release Tag | ||
|
||
|
||
on: | ||
push: | ||
tags: | ||
- 'v[0-9]+.[0-9]+.[0-9]+' | ||
- 'v[0-9]+.[0-9]+.[0-9]+-pr[0-9]+-rc.[0-9]+' | ||
|
||
|
||
jobs: | ||
tag: | ||
name: Release git tag | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Read Pushed Tag | ||
id: tag | ||
uses: GRESB/action-git-tag@main | ||
with: | ||
read: true | ||
ref: ${{ github.ref }} | ||
- name: Set commit status as pending | ||
uses: myrotvorets/set-commit-status-action@1.1.5 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
status: pending | ||
context: Create release (push tag) | ||
sha: ${{ steps.tag.outputs.sha }} | ||
targetUrl: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Release | ||
uses: ./ | ||
with: | ||
name: ${{ steps.tag.outputs.tag }} | ||
is-final: ${{ steps.tag.outputs.is-final }} | ||
pr-number: ${{ steps.tag.outputs.pr-number }} | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
body: | | ||
Release action executed! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Continues Delivery - Tag | ||
|
||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
|
||
jobs: | ||
tag: | ||
name: Create a git tag | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Git tag | ||
uses: GRESB/action-git-tag@main | ||
with: | ||
create: true | ||
github-token: ${{ secrets.BOT_PAT }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Continues Integration - PR Tag | ||
|
||
|
||
on: | ||
pull_request: | ||
branches: | ||
- '*' | ||
|
||
|
||
jobs: | ||
tag: | ||
name: Create a git tag | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Create git tag | ||
uses: GRESB/action-git-tag@main | ||
with: | ||
create: true | ||
pr-number: ${{ github.event.pull_request.number }} | ||
github-token: ${{ secrets.BOT_PAT }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,124 @@ | ||
# action-release | ||
A GitHub Action to release tags | ||
|
||
A GitHub Action to release tags. | ||
This is a composite action that combines other actions, like: | ||
|
||
- metcalfc/changelog-generator | ||
- softprops/action-gh-release | ||
- peter-evans/find-comment | ||
- chuhlomin/render-template | ||
- peter-evans/create-or-update-comment | ||
|
||
This action is mean to execute when new git tags are pushed (see how to create tags | ||
with [action-git-tag](https://github.com/GRESB/action-git-tag)). | ||
When invoked this action will create a change log, and a release (including the change log and user supplied input). | ||
If a PR number has been supplied it will look for a comment in that PR that contains a tag comment header. | ||
If the PR comment is found it will be updated, otherwise a new one is created with information about the release. | ||
|
||
## Inputs | ||
|
||
| Input | Description | Required | Default | | ||
|--------------------|---------------------------------------------------------------------------------------------|----------|---------------------------------------------------------------------------------------| | ||
| name | The name of the release. | true | | | ||
| is-final | Whether the release is a final release (eg v1.2.3). | true | | | ||
| pr-number | The PR number of the tag is meant for a release candidate. | false | | | ||
| tag-comment-header | The header on the PR tag comment, used to update the comment and to find existing comments. | false | '## Tag created' | | ||
| body | The text to post on the release. | true | | | ||
| workflow-run-url | The url of the workflow run. | false | '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' | | ||
| github-token | The GitHub token used for creating the tag. | true | | | ||
|
||
## Usage | ||
|
||
The default `secrets.GITHUB_TOKEN` is able to create the release and comment on the pull request. | ||
|
||
To create pull request comments, the action needs a template under `.github/templates/tag-comment.md`, with the | ||
following variables. | ||
|
||
```md | ||
{{ .header }} | ||
|
||
Tag: `{{ .tag }}` | ||
|
||
{{ .body }} | ||
|
||
{{ .footer }} | ||
``` | ||
|
||
The template can contain any other static text. | ||
|
||
### Create a final release | ||
|
||
```yaml | ||
name: Release Final Tag | ||
|
||
|
||
on: | ||
push: | ||
tags: | ||
- 'v[0-9]+.[0-9]+.[0-9]+' | ||
|
||
|
||
jobs: | ||
tag: | ||
name: Release git tag | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Read Pushed Tag | ||
id: tag | ||
uses: GRESB/action-git-tag@main | ||
with: | ||
read: true | ||
ref: ${{ github.ref }} | ||
- name: Release | ||
uses: ./ | ||
with: | ||
name: ${{ steps.tag.outputs.tag }} | ||
is-final: ${{ steps.tag.outputs.is-final }} | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
body: | | ||
### Artifacts | ||
- Container image: | ||
```some-container-image:${{ steps.tag.outputs.tag }}``` | ||
``` | ||
### Create a release candidate for a pull request | ||
```yaml | ||
name: Release Candidate Tag - Pull Request | ||
|
||
|
||
on: | ||
push: | ||
tags: | ||
- 'v[0-9]+.[0-9]+.[0-9]+-pr1234-rc.2' | ||
|
||
|
||
jobs: | ||
tag: | ||
name: Release git tag | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Read Pushed Tag | ||
id: tag | ||
uses: GRESB/action-git-tag@main | ||
with: | ||
read: true | ||
ref: ${{ github.ref }} | ||
- name: Release | ||
uses: ./ | ||
with: | ||
name: ${{ steps.tag.outputs.tag }} | ||
is-final: ${{ steps.tag.outputs.is-final }} | ||
pr-number: ${{ steps.tag.outputs.pr-number }} | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
body: | | ||
### Artifacts | ||
- Container image: | ||
```some-container-image:${{ steps.tag.outputs.tag }}``` | ||
``` | ||
### Create a release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
name: 'Release' | ||
description: 'Create a GitHub release from a git tag.' | ||
inputs: | ||
name: | ||
description: 'The name of the release.' | ||
required: true | ||
is-final: | ||
description: 'Whether the release is a final release (eg v1.2.3).' | ||
required: true | ||
pr-number: | ||
description: 'The PR number of the tag is meant for a release candidate.' | ||
required: false | ||
tag-comment-header: | ||
description: 'The header on the PR tag comment, used to update the comment and to find existing comments.' | ||
required: false | ||
default: "## Tag created" | ||
body: | ||
description: 'The text to post on the release.' | ||
required: true | ||
workflow-run-url: | ||
description: 'The url of the workflow run.' | ||
required: false | ||
default: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' | ||
github-token: | ||
description: 'The GitHub token used for creating the tag.' | ||
required: true | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Generate changelog | ||
id: changelog | ||
uses: metcalfc/changelog-generator@v4.0.1 | ||
with: | ||
myToken: ${{ inputs.github-token }} | ||
- name: Create Release | ||
uses: softprops/action-gh-release@v0.1.14 | ||
with: | ||
name: Release ${{ inputs.name }} | ||
body: | | ||
${{ inputs.body }} | ||
## Change log | ||
${{ steps.changelog.outputs.changelog }} | ||
draft: false | ||
prerelease: ${{ inputs.is-final == 'false' }} | ||
env: | ||
GITHUB_TOKEN: ${{ inputs.github-token }} | ||
- name: Find Tag Comment | ||
uses: peter-evans/find-comment@v2 | ||
if: inputs.pr-number | ||
id: find-tag-comment | ||
with: | ||
issue-number: ${{ inputs.pr-number }} | ||
comment-author: 'github-actions[bot]' | ||
body-includes: ${{ inputs.tag-comment-header }} | ||
direction: last | ||
- name: Prepare tag comment content | ||
id: tag-comment | ||
shell: bash | ||
if: inputs.pr-number | ||
run: | | ||
echo "tag_comment_body<<END_OF_VALUE" >> "${GITHUB_OUTPUT}" | ||
echo "Release: [${release}](https://github.com/GRESB/test-github-actions/releases/tag/${release})" >> "${GITHUB_OUTPUT}" | ||
echo "" >> "${GITHUB_OUTPUT}" | ||
echo "" >> "${GITHUB_OUTPUT}" | ||
echo "${body}" >> "${GITHUB_OUTPUT}" | ||
echo "END_OF_VALUE" >> "${GITHUB_OUTPUT}" | ||
footer="<sub><sup>*Generated by [workflow ${{ github.run_id }}](${{ inputs.workflow-run-url }})*" | ||
if [[ "${{ steps.find-tag-comment.outputs.comment-id }}" != "" ]]; then | ||
echo "DEBUG :: comment updated" | ||
updated="(comment updated ♻️)" | ||
fi | ||
echo "footer=${footer} ${updated}</sup></sub>" >> "${GITHUB_OUTPUT}" | ||
env: | ||
release: ${{ inputs.name }} | ||
body: ${{ inputs.body }} | ||
- name: Render release comment template | ||
uses: chuhlomin/render-template@v1.6 | ||
if: inputs.pr-number | ||
id: template | ||
with: | ||
template: .github/templates/tag-comment.md | ||
vars: | | ||
header: "${{ inputs.tag-comment-header }}" | ||
tag: ${{ inputs.name }} | ||
body: "${{ steps.tag-comment.outputs.tag_comment_body }}" | ||
footer: "${{ steps.tag-comment.outputs.footer }}" | ||
- name: Create or update comment | ||
uses: peter-evans/create-or-update-comment@v2 | ||
if: inputs.pr-number | ||
with: | ||
comment-id: ${{ steps.find-tag-comment.outputs.comment-id }} | ||
issue-number: ${{ inputs.pr-number }} | ||
body: ${{ steps.template.outputs.result }} | ||
edit-mode: replace |