This repository has been archived by the owner on Jan 22, 2024. It is now read-only.
generated from insightsengineering/r.pkg.template
-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (78 loc) · 2.82 KB
/
release.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
---
name: Release 🚀
on:
push:
tags:
- "v*"
workflow_call:
secrets:
GITHUB_TOKEN:
description: |
Github token with write access to the repository
required: false
inputs:
create-rc-releases:
description: Whether releases for RC tags (e.g. v0.0.1-rc1) should be created?
required: false
default: false
type: boolean
package-subdirectory:
description: Subdirectory in the repository, where the R package is located.
required: false
type: string
default: "."
workflow_dispatch:
concurrency:
group: release-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
release:
name: Release 🚀
runs-on: ubuntu-latest
if: "! contains(github.event.commits[0].message, '[skip release]')"
permissions:
contents: write
steps:
- name: Setup token 🔑
id: github-token
run: |
if [ "${{ secrets.GITHUB_TOKEN }}" == "" ]; then
echo "GITHUB_TOKEN is empty. Substituting it with GITHUB_TOKEN."
echo "token=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_OUTPUT
else
echo "Using GITHUB_TOKEN."
echo "token=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Checkout repo 🛎
uses: actions/checkout@v4
- name: Get branch names 🌿
id: branch-name
uses: tj-actions/branch-names@v7
- name: Check if running for rc tag 🏷️
id: rc-tag
run: |
echo "Current tag: ${{ steps.branch-name.outputs.tag }}"
current_tag="${{ steps.branch-name.outputs.tag }}"
if [ "$(echo "$current_tag" | grep -E "^v([0-9]+\.)?([0-9]+\.)?([0-9]+)(-rc[0-9]+)$")" != "" ]; then
echo "Running for rc-tag."
echo "is-rc-tag=true" >> $GITHUB_OUTPUT
else
echo "is-rc-tag=false" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Generate Changelog 📜
run: |
RELEASE_VERSION=$(awk -F: '/Version:/{gsub(/[ ]+/,"") ; print $2}' DESCRIPTION)
REPOSITORY_NAME="${{ github.event.repository.name }}"
(awk "/^#+.*${REPOSITORY_NAME//./\.}.*${RELEASE_VERSION//./\.}$/{flag=1;next}/^#+.*${REPOSITORY_NAME//./\.}.*/{flag=0}flag" NEWS.md | grep -v "^$" || echo "* ${RELEASE_VERSION}") > RELEASE_BODY.txt
working-directory: ${{ inputs.package-subdirectory }}
- name: Create release 🌟
if: >-
steps.rc-tag.outputs.is-rc-tag == 'false' ||
inputs.create-rc-releases == true
uses: softprops/action-gh-release@v1
with:
body_path: ${{ inputs.package-subdirectory }}/RELEASE_BODY.txt
token: ${{ steps.github-token.outputs.token }}
generate_release_notes: true