Skip to content

Add minimal GitHub release creation template workflow #149

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

Merged
merged 1 commit into from
Aug 18, 2021
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/release-tag.md
name: Release

on:
push:
tags:
- "v?[0-9]+.[0-9]+.[0-9]+*"

jobs:
release:
runs-on: ubuntu-latest

env:
# See: https://github.com/fsaintjacques/semver-tool/releases
SEMVER_TOOL_VERSION: 3.2.0

steps:
- name: Set environment variables
run: |
# See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
echo "CHANGELOG_PATH=${{ runner.temp }}/CHANGELOG.md" >> "$GITHUB_ENV"
echo "SEMVER_TOOL_PATH=${{ runner.temp }}/semver" >> "$GITHUB_ENV"

- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Create changelog
uses: arduino/create-changelog@v1
with:
tag-regex: '^v?[0-9]+\.[0-9]+\.[0-9]+.*$'
filter-regex: '^\[(skip|changelog)[ ,-](skip|changelog)\].*'
case-insensitive-regex: true
changelog-file-path: ${{ env.CHANGELOG_PATH }}

- name: Download semver tool
id: download-semver-tool
uses: carlosperate/[email protected]
with:
file-url: https://github.com/fsaintjacques/semver-tool/archive/${{ env.SEMVER_TOOL_VERSION }}.zip
location: ${{ runner.temp }}/semver-tool

- name: Install semver tool
run: |
unzip \
-p \
"${{ steps.download-semver-tool.outputs.file-path }}" \
semver-tool-${{ env.SEMVER_TOOL_VERSION }}/src/semver > \
"${{ env.SEMVER_TOOL_PATH }}"
chmod +x "${{ env.SEMVER_TOOL_PATH }}"

- name: Identify Prerelease
id: prerelease
run: |
if [[ "$("${{ env.SEMVER_TOOL_PATH }}" get prerel "${GITHUB_REF/refs\/tags\//}")" ]]; then echo "::set-output name=IS_PRE::true"; fi

- name: Create Github release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
bodyFile: ${{ env.CHANGELOG_PATH }}
draft: false
prerelease: ${{ steps.prerelease.outputs.IS_PRE }}
48 changes: 48 additions & 0 deletions workflow-templates/release-tag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# "Release" workflow

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.

## Installation

### Workflow

Install the [`release-tag.yml`](release-tag.yml) GitHub Actions workflow to `.github/workflows/`

### Readme badge

Markdown badge:

```markdown
[![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)
```

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)).

---

Asciidoc badge:

```adoc
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"]
```

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)).

## Commit message

```
Add GitHub Actions workflow to generate releases

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
changelog generated from the commit history since the last release tag.

Tags that contain a pre-release version will cause the GitHub release to be marked as a pre-release.
```

## PR message

```markdown
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.

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.
```
64 changes: 64 additions & 0 deletions workflow-templates/release-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/release-tag.md
name: Release

on:
push:
tags:
- "v?[0-9]+.[0-9]+.[0-9]+*"

jobs:
release:
runs-on: ubuntu-latest

env:
# See: https://github.com/fsaintjacques/semver-tool/releases
SEMVER_TOOL_VERSION: 3.2.0

steps:
- name: Set environment variables
run: |
# See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
echo "CHANGELOG_PATH=${{ runner.temp }}/CHANGELOG.md" >> "$GITHUB_ENV"
echo "SEMVER_TOOL_PATH=${{ runner.temp }}/semver" >> "$GITHUB_ENV"

- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Create changelog
uses: arduino/create-changelog@v1
with:
tag-regex: '^v?[0-9]+\.[0-9]+\.[0-9]+.*$'
filter-regex: '^\[(skip|changelog)[ ,-](skip|changelog)\].*'
case-insensitive-regex: true
changelog-file-path: ${{ env.CHANGELOG_PATH }}

- name: Download semver tool
id: download-semver-tool
uses: carlosperate/[email protected]
with:
file-url: https://github.com/fsaintjacques/semver-tool/archive/${{ env.SEMVER_TOOL_VERSION }}.zip
location: ${{ runner.temp }}/semver-tool

- name: Install semver tool
run: |
unzip \
-p \
"${{ steps.download-semver-tool.outputs.file-path }}" \
semver-tool-${{ env.SEMVER_TOOL_VERSION }}/src/semver > \
"${{ env.SEMVER_TOOL_PATH }}"
chmod +x "${{ env.SEMVER_TOOL_PATH }}"

- name: Identify Prerelease
id: prerelease
run: |
if [[ "$("${{ env.SEMVER_TOOL_PATH }}" get prerel "${GITHUB_REF/refs\/tags\//}")" ]]; then echo "::set-output name=IS_PRE::true"; fi

- name: Create Github release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
bodyFile: ${{ env.CHANGELOG_PATH }}
draft: false
prerelease: ${{ steps.prerelease.outputs.IS_PRE }}