Repository navigation
170 lines (163 loc) · 8.02 KB
/
Copy pathrelease.yml
File metadata and controls
170 lines (163 loc) · 8.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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# A release runs when a version tag is pushed (`git tag 0.4.0-beta && git push origin 0.4.0-beta`)
# or when someone starts it from the Actions tab with a version. With `publish` unticked it builds
# and smoke-tests every archive without publishing anything. A run started by hand can also limit
# the release to Linux, or to Linux and macOS (`platforms`), and leave out the VS Code extension
# (`vscode`). Every run also runs the tests of test.yml and the full gate of ci.yml on the release
# commit, and nothing is published unless both pass.
# The checklist and the one-time Marketplace setup are in
# docs/src/content/docs/development/releasing.md. Past runner setup, every step runs a `just`
# recipe or tools/smoke-test.sh, so each one also runs locally.
name: Release
on:
push:
tags: ["[0-9]+.[0-9]+.[0-9]+*"]
workflow_dispatch:
inputs:
version:
description: "Version to release, without a leading v (must equal workspace.package.version)"
required: true
publish:
description: "Publish the GitHub release and the VS Code extension (unticked builds and smoke-tests only)"
type: boolean
default: true
platforms:
description: "Platforms to build and release (a tag push always builds all)"
type: choice
options: [all, unix, linux]
default: all
vscode:
description: "Package and publish the VS Code extension"
type: boolean
default: true
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
VERSION: ${{ inputs.version || github.ref_name }}
jobs:
# The checks of test.yml: the fixture suites, the tests that need no GNU R and a bounded fuzz pass.
# `publish` needs them, so a release with a failing test builds its archives and publishes
# nothing.
tests:
uses: ./.github/workflows/test.yml
# The release gate: ci.yml's comparison with GNU R and its collection-stress pass, on the commit
# being released. `publish` needs it, so a release from a commit that fails it publishes nothing.
gate:
uses: ./.github/workflows/ci.yml
secrets: inherit
build:
name: build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
# ubuntu-22.04 is the oldest supported runner, so the Linux archive needs no newer glibc than
# 2.35. The Windows target is gnullvm because it links the UCRT, as Rtools-built packages do,
# so ry.exe, R.dll and package DLLs share one C runtime. The `linux` choice of `platforms`
# keeps the Linux entry alone, and `unix` keeps Linux and macOS.
matrix:
include: ${{ fromJSON(inputs.platforms == 'linux' && '[{"os":"ubuntu-22.04","target":"x86_64-unknown-linux-gnu"}]' || inputs.platforms == 'unix' && '[{"os":"ubuntu-22.04","target":"x86_64-unknown-linux-gnu"},{"os":"macos-15","target":"aarch64-apple-darwin"}]' || '[{"os":"ubuntu-22.04","target":"x86_64-unknown-linux-gnu"},{"os":"macos-15","target":"aarch64-apple-darwin"},{"os":"windows-latest","target":"x86_64-pc-windows-gnullvm"}]') }}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: extractions/setup-just@v2
- name: versions match the release
run: just release-check "$VERSION"
# Reads rust-toolchain.toml, so the release builds with the pinned nightly. An empty
# `rustflags` keeps the action's `-D warnings` from failing a release over a warning.
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
rustflags: ""
target: ${{ matrix.target }}
# GNU R for the smoke test's `ry R` and the CRAN package it installs (`ry run` uses the base R
# built into `ry`), and on Windows for Rtools, which `ry install` compiles with.
- uses: r-lib/actions/setup-r@v2
# The gnullvm target needs an LLVM mingw toolchain: clang to compile libr's C and drive lld,
# the UCRT import libraries, llvm-objdump for `just package`'s import check, and windres for
# ry.exe's UTF-8 manifest (crates/ry/build.rs). MSYS2's clang64 environment is that
# toolchain. It goes on PATH after setup-r, so its clang comes before anything Rtools puts
# there.
- uses: msys2/setup-msys2@v2
id: msys2
if: runner.os == 'Windows'
with:
msystem: CLANG64
update: false
install: mingw-w64-clang-x86_64-toolchain
- name: mingw toolchain
if: runner.os == 'Windows'
run: |
printf '%s\n' '${{ steps.msys2.outputs.msys2-location }}\clang64\bin' >> "$GITHUB_PATH"
{
echo "CARGO_TARGET_X86_64_PC_WINDOWS_GNULLVM_LINKER=clang"
echo "CC_x86_64_pc_windows_gnullvm=clang"
echo "AR_x86_64_pc_windows_gnullvm=llvm-ar"
echo "WINDRES=llvm-windres"
} >> "$GITHUB_ENV"
# libR links zlib, bzip2 and xz on Linux, as GNU R's does (crates/libr/build.rs).
- name: link libraries
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y zlib1g-dev libbz2-dev liblzma-dev
# `just package` builds Linux with profile-guided optimization and BOLT
# (tools/layout/optimize.sh). Its training runs the representative workload mix, which needs
# these packages, and BOLT comes from LLVM's apt repository because ubuntu-22.04 has no
# llvm-bolt.
- name: layout tools
if: runner.os == 'Linux'
run: |
curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-20 main" | sudo tee /etc/apt/sources.list.d/llvm-20.list
sudo apt-get update && sudo apt-get install -y bolt-20
Rscript -e 'packages <- c("testthat", "purrr", "stringr", "lubridate", "data.table", "xts", "zoo"); install.packages(packages); stopifnot(all(vapply(packages, requireNamespace, NA, quietly = TRUE)))'
# Two release target directories and the instrumented fat-LTO link need more disk than the
# runner has free.
sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc /opt/hostedtoolcache/CodeQL
- name: package
run: just package "$VERSION" ${{ matrix.target }}
# RY_SMOKE_PACKAGES installs jsonlite with GNU R and loads it under `ry run`: a CRAN binary on
# macOS, which proves ry rebinds a GNU R package's libR to its own runtime, a CRAN binary
# built with Rtools on Windows, which proves such a DLL binds to ry's R.dll, and a source
# build on Linux.
- name: smoke test
env:
RY_SMOKE_PACKAGES: "1"
run: tools/smoke-test.sh "release/$VERSION/ry-${{ matrix.target }}".*
- uses: actions/upload-artifact@v4
with:
name: ry-${{ matrix.target }}
path: |
release/${{ env.VERSION }}/ry-${{ matrix.target }}.tar.gz
release/${{ env.VERSION }}/ry-${{ matrix.target }}.zip
if-no-files-found: error
publish:
name: publish
needs: [build, tests, gate]
if: github.event_name == 'push' || inputs.publish
runs-on: ubuntu-latest
permissions:
# Creates the GitHub release (and its tag, for a run started by hand).
contents: write
# Lets vsce trade a GitHub OIDC token for a short-lived Marketplace credential (trusted
# publishing), so no Marketplace token is stored in the repository.
id-token: write
steps:
- uses: actions/checkout@v4
- uses: extractions/setup-just@v2
- uses: oven-sh/setup-bun@v2
# vsce 4.1, which publishes with trusted publishing, needs node 22.
- uses: actions/setup-node@v4
with:
node-version: 22
- uses: actions/download-artifact@v4
with:
path: release/${{ env.VERSION }}
merge-multiple: true
- name: package the VS Code extension
if: github.event_name == 'push' || inputs.vscode
run: just release-assets "$VERSION"
- name: publish
env:
GH_TOKEN: ${{ github.token }}
VSCE_PAT: ${{ secrets.VSCE_PAT }}
run: just release-publish "$VERSION"