Skip to content

Commit b11cc56

Browse files
author
Raphael Sonabend
authored
Create make-release.yml
1 parent e149bb2 commit b11cc56

File tree

1 file changed

+155
-0
lines changed

1 file changed

+155
-0
lines changed

.github/workflows/make-release.yml

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
on:
2+
push:
3+
branches:
4+
- master
5+
6+
name: make-release
7+
8+
jobs:
9+
build-binaries:
10+
runs-on: ${{ matrix.config.os }}
11+
12+
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
13+
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
config:
18+
- {os: macOS-latest, r: 'release'}
19+
- {os: windows-latest, r: 'release'}
20+
- {os: macOS-latest, r: 'oldrel'}
21+
- {os: windows-latest, r: 'oldrel'}
22+
23+
env:
24+
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
25+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
26+
27+
steps:
28+
- uses: actions/checkout@v2
29+
30+
- uses: r-lib/actions/setup-r@master
31+
with:
32+
r-version: ${{ matrix.config.r }}
33+
34+
- uses: r-lib/actions/setup-pandoc@master
35+
36+
- name: Query dependencies
37+
run: |
38+
install.packages('remotes')
39+
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
40+
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
41+
shell: Rscript {0}
42+
43+
- name: Cache R packages
44+
uses: actions/cache@v1
45+
with:
46+
path: ${{ env.R_LIBS_USER }}
47+
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
48+
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
49+
50+
- name: Install dependencies
51+
run: |
52+
install.packages(c("remotes"))
53+
remotes::install_deps(dependencies = TRUE)
54+
remotes::install_cran("pkgbuild")
55+
remotes::install_cran("covr")
56+
shell: Rscript {0}
57+
58+
# Properly, should build source first!
59+
- name: Build binary
60+
shell: Rscript {0}
61+
run: |
62+
src <- pkgbuild::build(".", dest_path = tempdir())
63+
bin <- pkgbuild::build(".", dest_path = tempdir(), binary = TRUE)
64+
dir.create("build")
65+
file.copy(c(src, bin), "build")
66+
67+
- name: Upload package
68+
if: success()
69+
uses: actions/upload-artifact@v2
70+
with:
71+
name: pkg-${{ matrix.config.os }}-${{ matrix.config.r }}
72+
path: build
73+
74+
create-release:
75+
runs-on: ubuntu-20.04
76+
77+
needs: build-binaries
78+
79+
steps:
80+
- uses: actions/checkout@v2
81+
82+
- name: Extract version
83+
run: |
84+
echo "PACKAGE_VERSION=$(grep '^Version' DESCRIPTION | sed 's/.*: *//')" >> $GITHUB_ENV
85+
echo "PACKAGE_NAME=$(grep '^Package' DESCRIPTION | sed 's/.*: *//')" >> $GITHUB_ENV
86+
87+
- uses: actions/download-artifact@v2
88+
with:
89+
path: pkg
90+
91+
- name: Show directory
92+
shell: bash
93+
run: |
94+
ls -R
95+
96+
- name: Create Release
97+
id: create_release
98+
uses: actions/create-release@v1
99+
env:
100+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101+
with:
102+
tag_name: v${{ env.PACKAGE_VERSION }}
103+
release_name: Release ${{ env.PACKAGE_NAME }} ${{ env.PACKAGE_VERSION }}
104+
draft: false
105+
prerelease: false
106+
107+
- name: Upload source
108+
uses: actions/upload-release-asset@v1
109+
env:
110+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111+
with:
112+
upload_url: ${{ steps.create_release.outputs.upload_url }}
113+
asset_path: pkg/pkg-macOS-latest-release/${{ env.PACKAGE_NAME }}_${{ env.PACKAGE_VERSION }}.tar.gz
114+
asset_name: ${{ env.PACKAGE_NAME }}_${{ env.PACKAGE_VERSION }}.tar.gz
115+
asset_content_type: application/gzip
116+
117+
- name: Upload macOS binary
118+
uses: actions/upload-release-asset@v1
119+
env:
120+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
121+
with:
122+
upload_url: ${{ steps.create_release.outputs.upload_url }}
123+
asset_path: pkg/pkg-macOS-latest-release/${{ env.PACKAGE_NAME }}_${{ env.PACKAGE_VERSION }}.tgz
124+
asset_name: ${{ env.PACKAGE_NAME }}_${{ env.PACKAGE_VERSION }}.tgz
125+
asset_content_type: application/gzip
126+
127+
- name: Upload Windows binary
128+
uses: actions/upload-release-asset@v1
129+
env:
130+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
131+
with:
132+
upload_url: ${{ steps.create_release.outputs.upload_url }}
133+
asset_path: pkg/pkg-windows-latest-release/${{ env.PACKAGE_NAME }}_${{ env.PACKAGE_VERSION }}.zip
134+
asset_name: ${{ env.PACKAGE_NAME }}_${{ env.PACKAGE_VERSION }}.zip
135+
asset_content_type: application/zip
136+
137+
- name: Upload macOS binary
138+
uses: actions/upload-release-asset@v1
139+
env:
140+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
141+
with:
142+
upload_url: ${{ steps.create_release.outputs.upload_url }}
143+
asset_path: pkg/pkg-macOS-latest-oldrel/${{ env.PACKAGE_NAME }}_${{ env.PACKAGE_VERSION }}.tgz
144+
asset_name: ${{ env.PACKAGE_NAME }}_${{ env.PACKAGE_VERSION }}_oldrel.tgz
145+
asset_content_type: application/gzip
146+
147+
- name: Upload Windows binary
148+
uses: actions/upload-release-asset@v1
149+
env:
150+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
151+
with:
152+
upload_url: ${{ steps.create_release.outputs.upload_url }}
153+
asset_path: pkg/pkg-windows-latest-oldrel/${{ env.PACKAGE_NAME }}_${{ env.PACKAGE_VERSION }}.zip
154+
asset_name: ${{ env.PACKAGE_NAME }}_${{ env.PACKAGE_VERSION }}_oldrel.zip
155+
asset_content_type: application/zip

0 commit comments

Comments
 (0)