-
Notifications
You must be signed in to change notification settings - Fork 1
109 lines (90 loc) · 3.85 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Packages and creates a Github Release which can be used to control release flow.
# This should eventually be replaced by a release to CRAN.
# NOTE this will fail if the tag and DESCRIPTION file is out of sync.
---
name: Release
on:
workflow_call:
inputs:
create-dev-releases:
description: 'Create dev releases'
required: false
default: false
type: boolean
is-pre-release:
description: 'Mark as pre-release'
required: false
default: false
type: boolean
workflow_dispatch:
concurrency:
group: release-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
release:
name: Release 🚀
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Setup token 🔑
id: github-token
run: |
if [ "${{ secrets.REPO_GITHUB_TOKEN }}" == "" ]; then
echo "REPO_GITHUB_TOKEN is empty. Substituting it with GITHUB_TOKEN."
echo "token=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_OUTPUT
else
echo "Using REPO_GITHUB_TOKEN."
echo "token=${{ secrets.REPO_GITHUB_TOKEN }}" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Checkout repo 🛎
uses: actions/checkout@v4
- uses: r-lib/actions/setup-pandoc@v2
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: |
any::rcmdcheck
any::knitr
any::pkgdown
- name: Get branch names 🌿
id: branch-name
uses: tj-actions/branch-names@v7
- name: Create pkg tarball 📦
run: |
R CMD build .
shell: bash
- name: Get package build filename 📦
run: |
echo "PKGBUILD=$(echo $(awk -F: '/Package:/{gsub(/[ ]+/,"") ; print $2}' DESCRIPTION)_"\
"$(awk -F: '/Version:/{gsub(/[ ]+/,"") ; print $2}' DESCRIPTION).tar.gz)" >> $GITHUB_ENV
shell: bash
- name: Get package version
run: |
echo "PACKAGE_VERSION=v$(awk -F: '/Version:/{gsub(/[ ]+/,"") ; print $2}' DESCRIPTION)" >> $GITHUB_ENV
shell: bash
# Generates a small text describing the changes requires a NEWS.md file with appropriate vX.Y.Z header.
- 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
# This will create a Github Release based on the current tag
# The Release will contain the code as a tarball but also include License and Changelog.
- name: Create release 🌟
# https://github.com/softprops/action-gh-release/pull/406#issuecomment-1934635958
uses: softprops/action-gh-release@4634c16e79c963813287e889244c50009e7f0981
with:
body_path: RELEASE_BODY.txt
token: ${{ steps.github-token.outputs.token }}
generate_release_notes: true
name: ${{ env.PACKAGE_VERSION }}
tag_name: ${{ env.PACKAGE_VERSION}}
files: |
LICENSE
LICENSE.md
${{ env.PKGBUILD }}
prerelease: inputs.pre-release