| 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 |
permissions: |
| 13 |
contents: write |
| 14 |
|
| 15 |
env: |
| 16 |
# See: https://github.com/fsaintjacques/semver-tool/releases |
| 17 |
SEMVER_TOOL_VERSION: 3.2.0 |
| 18 |
|
| 19 |
steps: |
| 20 |
- name: Set environment variables |
| 21 |
run: | |
| 22 |
# See: https://docs.github.com/actions/reference/workflows-and-actions/workflow-commands#setting-an-environment-variable |
| 23 |
echo "CHANGELOG_PATH=${{ runner.temp }}/CHANGELOG.md" >>"$GITHUB_ENV" |
| 24 |
echo "SEMVER_TOOL_PATH=${{ runner.temp }}/semver" >>"$GITHUB_ENV" |
| 25 |
|
| 26 |
- name: Checkout repository |
| 27 |
uses: actions/checkout@v7 |
| 28 |
with: |
| 29 |
fetch-depth: 0 |
| 30 |
|
| 31 |
- name: Create changelog |
| 32 |
uses: arduino/create-changelog@v1 |
| 33 |
with: |
| 34 |
tag-regex: '^v?[0-9]+\.[0-9]+\.[0-9]+.*$' |
| 35 |
filter-regex: '^\[(skip|changelog)[ ,-](skip|changelog)\].*' |
| 36 |
case-insensitive-regex: true |
| 37 |
changelog-file-path: ${{ env.CHANGELOG_PATH }} |
| 38 |
|
| 39 |
- name: Download semver tool |
| 40 |
id: download-semver-tool |
| 41 |
uses: carlosperate/download-file-action@v2 |
| 42 |
with: |
| 43 |
file-url: https://github.com/fsaintjacques/semver-tool/archive/${{ env.SEMVER_TOOL_VERSION }}.zip |
| 44 |
location: ${{ runner.temp }}/semver-tool |
| 45 |
|
| 46 |
- name: Install semver tool |
| 47 |
run: | |
| 48 |
unzip \ |
| 49 |
-p \ |
| 50 |
"${{ steps.download-semver-tool.outputs.file-path }}" \ |
| 51 |
semver-tool-${{ env.SEMVER_TOOL_VERSION }}/src/semver \ |
| 52 |
>"${{ env.SEMVER_TOOL_PATH }}" |
| 53 |
|
| 54 |
chmod \ |
| 55 |
+x \ |
| 56 |
"${{ env.SEMVER_TOOL_PATH }}" |
| 57 |
|
| 58 |
- name: Identify Prerelease |
| 59 |
id: prerelease |
| 60 |
run: | |
| 61 |
if [[ \ |
| 62 |
"$( |
| 63 |
"${{ env.SEMVER_TOOL_PATH }}" get prerel \ |
| 64 |
"${GITHUB_REF/refs\/tags\//}" |
| 65 |
)" != \ |
| 66 |
"" \ |
| 67 |
]]; then |
| 68 |
echo "IS_PRE=true" >>$GITHUB_OUTPUT |
| 69 |
fi |
| 70 |
|
| 71 |
- name: Create Github release |
| 72 |
uses: ncipollo/release-action@v1 |
| 73 |
with: |
| 74 |
token: ${{ secrets.GITHUB_TOKEN }} |
| 75 |
bodyFile: ${{ env.CHANGELOG_PATH }} |
| 76 |
draft: false |
| 77 |
prerelease: ${{ steps.prerelease.outputs.IS_PRE }} |