Skip to content

Commit a5657da

Browse files
authored
Merge pull request #149 from per1234/release-tag
Add minimal GitHub release creation template workflow
2 parents d1458ed + 992e95c commit a5657da

File tree

3 files changed

+176
-0
lines changed

3 files changed

+176
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/release-tag.md
2+
name: Release
3+
4+
on:
5+
push:
6+
tags:
7+
- "v?[0-9]+.[0-9]+.[0-9]+*"
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
13+
env:
14+
# See: https://github.com/fsaintjacques/semver-tool/releases
15+
SEMVER_TOOL_VERSION: 3.2.0
16+
17+
steps:
18+
- name: Set environment variables
19+
run: |
20+
# See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
21+
echo "CHANGELOG_PATH=${{ runner.temp }}/CHANGELOG.md" >> "$GITHUB_ENV"
22+
echo "SEMVER_TOOL_PATH=${{ runner.temp }}/semver" >> "$GITHUB_ENV"
23+
24+
- name: Checkout repository
25+
uses: actions/checkout@v2
26+
with:
27+
fetch-depth: 0
28+
29+
- name: Create changelog
30+
uses: arduino/create-changelog@v1
31+
with:
32+
tag-regex: '^v?[0-9]+\.[0-9]+\.[0-9]+.*$'
33+
filter-regex: '^\[(skip|changelog)[ ,-](skip|changelog)\].*'
34+
case-insensitive-regex: true
35+
changelog-file-path: ${{ env.CHANGELOG_PATH }}
36+
37+
- name: Download semver tool
38+
id: download-semver-tool
39+
uses: carlosperate/[email protected]
40+
with:
41+
file-url: https://github.com/fsaintjacques/semver-tool/archive/${{ env.SEMVER_TOOL_VERSION }}.zip
42+
location: ${{ runner.temp }}/semver-tool
43+
44+
- name: Install semver tool
45+
run: |
46+
unzip \
47+
-p \
48+
"${{ steps.download-semver-tool.outputs.file-path }}" \
49+
semver-tool-${{ env.SEMVER_TOOL_VERSION }}/src/semver > \
50+
"${{ env.SEMVER_TOOL_PATH }}"
51+
chmod +x "${{ env.SEMVER_TOOL_PATH }}"
52+
53+
- name: Identify Prerelease
54+
id: prerelease
55+
run: |
56+
if [[ "$("${{ env.SEMVER_TOOL_PATH }}" get prerel "${GITHUB_REF/refs\/tags\//}")" ]]; then echo "::set-output name=IS_PRE::true"; fi
57+
58+
- name: Create Github release
59+
uses: ncipollo/release-action@v1
60+
with:
61+
token: ${{ secrets.GITHUB_TOKEN }}
62+
bodyFile: ${{ env.CHANGELOG_PATH }}
63+
draft: false
64+
prerelease: ${{ steps.prerelease.outputs.IS_PRE }}

workflow-templates/release-tag.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# "Release" workflow
2+
3+
Make a [GitHub release](https://docs.github.com/en/github/administering-a-repository/releasing-projects-on-github/about-releases) with changelog on release [tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging) push.
4+
5+
## Installation
6+
7+
### Workflow
8+
9+
Install the [`release-tag.yml`](release-tag.yml) GitHub Actions workflow to `.github/workflows/`
10+
11+
### Readme badge
12+
13+
Markdown badge:
14+
15+
```markdown
16+
[![Release status](https://github.com/REPO_OWNER/REPO_NAME/actions/workflows/release-tag.yml/badge.svg)](https://github.com/REPO_OWNER/REPO_NAME/actions/workflows/release-tag.yml)
17+
```
18+
19+
Replace the `REPO_OWNER` and `REPO_NAME` placeholders in the URLs with the final repository owner and name ([example](https://raw.githubusercontent.com/arduino-libraries/ArduinoIoTCloud/master/README.md)).
20+
21+
---
22+
23+
Asciidoc badge:
24+
25+
```adoc
26+
image:https://github.com/{repository-owner}/{repository-name}/actions/workflows/release-tag.yml/badge.svg["Release status", link="https://github.com/{repository-owner}/{repository-name}/actions/workflows/release-tag.yml"]
27+
```
28+
29+
Define the `{repository-owner}` and `{repository-name}` attributes and use them throughout the readme ([example](https://raw.githubusercontent.com/arduino-libraries/WiFiNINA/master/README.adoc)).
30+
31+
## Commit message
32+
33+
```
34+
Add GitHub Actions workflow to generate releases
35+
36+
On every push of a release tag (e.g., "1.2.3" or "v1.2.3") to the repository, create a GitHub release with a raw
37+
changelog generated from the commit history since the last release tag.
38+
39+
Tags that contain a pre-release version will cause the GitHub release to be marked as a pre-release.
40+
```
41+
42+
## PR message
43+
44+
```markdown
45+
On every push of a release tag (e.g., `1.2.3` or `v1.2.3`) to the repository, create a [GitHub release](https://docs.github.com/en/github/administering-a-repository/releasing-projects-on-github/about-releases) with a raw [changelog generated](https://github.com/arduino/create-changelog) from the commit history since the last release tag.
46+
47+
Tags that contain a [pre-release version](https://semver.org/#spec-item-9) will cause the GitHub release to be marked as a pre-release.
48+
```

workflow-templates/release-tag.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/release-tag.md
2+
name: Release
3+
4+
on:
5+
push:
6+
tags:
7+
- "v?[0-9]+.[0-9]+.[0-9]+*"
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
13+
env:
14+
# See: https://github.com/fsaintjacques/semver-tool/releases
15+
SEMVER_TOOL_VERSION: 3.2.0
16+
17+
steps:
18+
- name: Set environment variables
19+
run: |
20+
# See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
21+
echo "CHANGELOG_PATH=${{ runner.temp }}/CHANGELOG.md" >> "$GITHUB_ENV"
22+
echo "SEMVER_TOOL_PATH=${{ runner.temp }}/semver" >> "$GITHUB_ENV"
23+
24+
- name: Checkout repository
25+
uses: actions/checkout@v2
26+
with:
27+
fetch-depth: 0
28+
29+
- name: Create changelog
30+
uses: arduino/create-changelog@v1
31+
with:
32+
tag-regex: '^v?[0-9]+\.[0-9]+\.[0-9]+.*$'
33+
filter-regex: '^\[(skip|changelog)[ ,-](skip|changelog)\].*'
34+
case-insensitive-regex: true
35+
changelog-file-path: ${{ env.CHANGELOG_PATH }}
36+
37+
- name: Download semver tool
38+
id: download-semver-tool
39+
uses: carlosperate/[email protected]
40+
with:
41+
file-url: https://github.com/fsaintjacques/semver-tool/archive/${{ env.SEMVER_TOOL_VERSION }}.zip
42+
location: ${{ runner.temp }}/semver-tool
43+
44+
- name: Install semver tool
45+
run: |
46+
unzip \
47+
-p \
48+
"${{ steps.download-semver-tool.outputs.file-path }}" \
49+
semver-tool-${{ env.SEMVER_TOOL_VERSION }}/src/semver > \
50+
"${{ env.SEMVER_TOOL_PATH }}"
51+
chmod +x "${{ env.SEMVER_TOOL_PATH }}"
52+
53+
- name: Identify Prerelease
54+
id: prerelease
55+
run: |
56+
if [[ "$("${{ env.SEMVER_TOOL_PATH }}" get prerel "${GITHUB_REF/refs\/tags\//}")" ]]; then echo "::set-output name=IS_PRE::true"; fi
57+
58+
- name: Create Github release
59+
uses: ncipollo/release-action@v1
60+
with:
61+
token: ${{ secrets.GITHUB_TOKEN }}
62+
bodyFile: ${{ env.CHANGELOG_PATH }}
63+
draft: false
64+
prerelease: ${{ steps.prerelease.outputs.IS_PRE }}

0 commit comments

Comments
 (0)