-
Notifications
You must be signed in to change notification settings - Fork 25
59 lines (51 loc) · 2.02 KB
/
Copy pathbuild-cran-package.yml
File metadata and controls
59 lines (51 loc) · 2.02 KB
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
name: Build CRAN package
# Builds the CRAN-ready source tarball (RClickhouse_<version>.tar.gz) with
# `R CMD build`, which respects .Rbuildignore and excludes VCS / CI files.
# The tarball is uploaded as a workflow artifact and, when triggered by a
# version tag, published as a release asset that can be uploaded directly
# to CRAN (https://cran.r-project.org/submit.html).
on:
push:
tags:
- 'v*' # e.g. push tag v0.6.11 to cut a release
workflow_dispatch: # allow building the tarball manually from the Actions tab
permissions:
contents: write # needed to create/update the GitHub release
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up R
uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- name: Build source tarball
run: |
R CMD build .
PKG_FILE="$(ls -1 RClickhouse_*.tar.gz | head -n1)"
echo "PKG_FILE=${PKG_FILE}" >> "$GITHUB_ENV"
echo "Built ${PKG_FILE}"
echo "::group::Tarball contents"
tar tzf "${PKG_FILE}"
echo "::endgroup::"
- name: Upload tarball as workflow artifact
uses: actions/upload-artifact@v4
with:
name: cran-package
path: RClickhouse_*.tar.gz
if-no-files-found: error
- name: Publish tarball to GitHub release
if: startsWith(github.ref, 'refs/tags/')
env:
GH_TOKEN: ${{ github.token }}
run: |
# Create the release if it does not exist yet, otherwise just add
# the asset (overwriting any previous upload with the same name).
if ! gh release view "${GITHUB_REF_NAME}" >/dev/null 2>&1; then
gh release create "${GITHUB_REF_NAME}" \
--title "${GITHUB_REF_NAME}" \
--notes "CRAN source package \`${PKG_FILE}\` — upload this file directly to CRAN."
fi
gh release upload "${GITHUB_REF_NAME}" "${PKG_FILE}" --clobber