Skip to content

Commit de5d174

Browse files
committed
Start preparing code for registration
1 parent 7ab9a18 commit de5d174

File tree

3 files changed

+77
-46
lines changed

3 files changed

+77
-46
lines changed

.ci/register_package.jl

Lines changed: 30 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ dependencies = Dependency[dep for dep in merged["dependencies"] if !(isa(dep, Bu
3030
lazy_artifacts = merged["lazy_artifacts"]
3131
augment_platform_block = merged["augment_platform_block"]
3232
build_version = BinaryBuilder.get_next_wrapper_version(name, version)
33-
repo = "JuliaBinaryWrappers/$(name)_jll.jl"
33+
repo = "EnzymeAD/$(name)_jll.jl"
3434
code_dir = joinpath(Pkg.devdir(), "$(name)_jll")
3535
julia_compat = merged["julia_compat"]
3636

@@ -54,17 +54,6 @@ function mvdir(src, dest)
5454
end
5555
end
5656

57-
function download_cached_binaries(download_dir)
58-
NAME = ENV["NAME"]
59-
PROJECT = ENV["PROJECT"]
60-
artifacts = "$(PROJECT)/products/$(NAME)*.tar.*"
61-
cmd = `buildkite-agent artifact download $artifacts $download_dir`
62-
if !success(pipeline(cmd; stderr))
63-
error("Download failed")
64-
end
65-
mvdir(joinpath(download_dir, PROJECT, "products"), download_dir)
66-
end
67-
6857
function download_binaries_from_release(download_dir)
6958
function do_download(download_dir, info)
7059
url = info["url"]
@@ -96,42 +85,40 @@ for json_obj in [merged, objs_unmerged...]
9685
json_obj["dependencies"] = Dependency[dep for dep in json_obj["dependencies"] if BinaryBuilderBase.is_runtime_dependency(dep)]
9786
end
9887
skip_build = get(ENV, "SKIP_BUILD", "false") == "true"
99-
mktempdir() do download_dir
100-
# Grab the binaries for our package
101-
if skip_build
102-
# We only want to update the wrappers, so download the tarballs from the
103-
# latest build.
104-
download_binaries_from_release(download_dir)
105-
else
106-
# We are going to publish the new binaries we've just baked, take them
107-
# out of the cache while they're hot.
108-
download_cached_binaries(download_dir)
109-
end
11088

111-
# Push up the JLL package (pointing to as-of-yet missing tarballs)
112-
tag = "$(name)-v$(build_version)"
113-
upload_prefix = "https://github.com/$(repo)/releases/download/$(tag)"
89+
# binaries will be automatically placed in the `products/` subdir by the GitHub
90+
# Actions workflow.
91+
download_dir = joinpath(pwd(), "products")
92+
# Grab the binaries for our package
93+
if skip_build
94+
# We only want to update the wrappers, so download the tarballs from the
95+
# latest build.
96+
download_binaries_from_release(download_dir)
97+
end
98+
99+
# Push up the JLL package (pointing to as-of-yet missing tarballs)
100+
tag = "$(name)-v$(build_version)"
101+
upload_prefix = "https://github.com/$(repo)/releases/download/$(tag)"
114102

115-
# If we didn't rebuild the tarballs, save the original Artifacts.toml
116-
artifacts_toml = skip_build ? read(joinpath(code_dir, "Artifacts.toml"), String) : ""
117-
# This loop over the unmerged objects necessary in the event that we have multiple packages being built by a single build_tarballs.jl
118-
for (i,json_obj) in enumerate(objs_unmerged)
119-
from_scratch = (i == 1)
120-
BinaryBuilder.rebuild_jll_package(json_obj; download_dir, upload_prefix, verbose, from_scratch)
121-
end
103+
# If we didn't rebuild the tarballs, save the original Artifacts.toml
104+
artifacts_toml = skip_build ? read(joinpath(code_dir, "Artifacts.toml"), String) : ""
105+
# This loop over the unmerged objects necessary in the event that we have multiple packages being built by a single build_tarballs.jl
106+
for (i,json_obj) in enumerate(objs_unmerged)
107+
from_scratch = (i == 1)
108+
BinaryBuilder.rebuild_jll_package(json_obj; download_dir, upload_prefix, verbose, from_scratch)
109+
end
122110

123-
# Restore Artifacts.toml
124-
if skip_build
125-
write(joinpath(code_dir, "Artifacts.toml"), artifacts_toml)
126-
end
111+
# Restore Artifacts.toml
112+
if skip_build
113+
write(joinpath(code_dir, "Artifacts.toml"), artifacts_toml)
114+
end
127115

128-
# Push JLL package _before_ uploading to GitHub releases, so that this version of the code is what gets tagged
129-
BinaryBuilder.push_jll_package(name, build_version)
116+
# Push JLL package _before_ uploading to GitHub releases, so that this version of the code is what gets tagged
117+
BinaryBuilder.push_jll_package(name, build_version)
130118

131-
if !skip_build
132-
# Upload the tarballs to GitHub releases
133-
BinaryBuilder.upload_to_github_releases(repo, tag, download_dir; verbose=verbose)
134-
end
119+
if !skip_build
120+
# Upload the tarballs to GitHub releases
121+
BinaryBuilder.upload_to_github_releases(repo, tag, download_dir; verbose=verbose)
135122
end
136123

137124
# Sub off to Registrator to create a PR to General. Note: it's important to pass both

.github/workflows/build-reactant-reusable.yml

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: "Build Reactant_jll"
22

33
on:
44
workflow_call:
5+
secrets:
6+
ENZYMEAD_BOT_ID:
7+
required: true
8+
ENZYMEAD_BOT_PRIVATE_KEY:
9+
required: true
510
inputs:
611
julia_version:
712
description: 'Julia version'
@@ -212,10 +217,29 @@ jobs:
212217
needs: build-platforms
213218

214219
steps:
220+
- uses: actions/create-github-app-token@v2
221+
id: generate_token
222+
with:
223+
app-id: "${{ secrets.ENZYMEAD_BOT_ID }}"
224+
private-key: "${{ secrets.ENZYMEAD_BOT_PRIVATE_KEY }}"
215225
- uses: actions/checkout@v5
216226
with:
217227
repository: 'EnzymeAD/ReactantBuilder'
218228
ref: ${{ inputs.reactantbuilder_ref == '' && github.sha || inputs.reactantbuilder_ref }}
229+
- name: Set JULIA_PROJECT
230+
# We have to use `${GITHUB_WORKSPACE}` instead of `github.workspace` because GitHub
231+
# is terrible and the two don't match inside containers:
232+
# https://github.com/actions/runner/issues/2058
233+
run:
234+
echo "JULIA_PROJECT=${GITHUB_WORKSPACE}/.ci" >> "${GITHUB_ENV}"
235+
- name: Set and create PRODUCTS_DIR
236+
# We have to use `${GITHUB_WORKSPACE}` instead of `github.workspace` because GitHub
237+
# is terrible and the two don't match inside containers:
238+
# https://github.com/actions/runner/issues/2058
239+
run: |
240+
PRODUCTS_DIR=${{ inputs.build_project }}/products
241+
mkdir -p "${PRODUCTS_DIR}"
242+
echo "PRODUCTS_DIR=${PRODUCTS_DIR}" >> "${GITHUB_ENV}"
219243
- uses: julia-actions/setup-julia@v2
220244
with:
221245
version: '${{ inputs.julia_version }}'
@@ -225,13 +249,32 @@ jobs:
225249
- uses: actions/download-artifact@v6
226250
with:
227251
merge-multiple: true
252+
path: ${{ env.PRODUCTS_DIR }}
228253
- name: Change Reactant commit
229254
run: |
230255
if [[ -n "${{ inputs.reactant_commit }}" ]]; then
231256
echo 'Changing Reactant commit to ${{ inputs.reactant_commit }}...'
232257
sed -i 's/reactant_commit = ".*"/reactant_commit = "'${{ inputs.reactant_commit }}'"/' R/Reactant/build_tarballs.jl
233258
fi
234-
- name: Check
259+
- name: Set up git
235260
run: |
236-
pwd
237-
ls -lhrt
261+
git config user.name "${{github.actor}}"
262+
git config user.email "${{github.actor_id}}+${{github.actor}}@users.noreply.github.com"
263+
- name: Instantiate environment
264+
timeout-minutes: 20
265+
shell: julia --color=yes {0}
266+
run: |
267+
using Pkg
268+
Pkg.instantiate()
269+
- name: Generate meta.json
270+
run: |
271+
julia --compile=min ./build_tarballs.jl --meta-json=$(basename ${{ inputs.build_project }}).meta.json
272+
working-directory: ${{ inputs.build_project }}
273+
env:
274+
GITHUB_TOKEN:
275+
- name: Register
276+
run: |
277+
julia ${JULIA_PROJECT}/register_package.jl "$(basename ${{ inputs.build_project }}).meta.json" --verbose
278+
working-directory: ${{ inputs.build_project }}
279+
env:
280+
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}

.github/workflows/build-reactant.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ jobs:
2020
strategy:
2121
fail-fast: false
2222
uses: ./.github/workflows/build-reactant-reusable.yml
23+
secrets: inherit

0 commit comments

Comments
 (0)