forked from astral-sh/python-build-standalone
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJustfile
More file actions
125 lines (109 loc) · 4.32 KB
/
Justfile
File metadata and controls
125 lines (109 loc) · 4.32 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
# Diff 2 releases using diffoscope.
diff a b:
diffoscope \
--html build/diff.html \
--exclude 'python/build/**' \
--exclude-command '^readelf.*' \
--exclude-command '^xxd.*' \
--exclude-command '^objdump.*' \
--exclude-command '^strings.*' \
--max-report-size 9999999999 \
--max-page-size 999999999 \
--max-diff-block-lines 100000 \
--max-page-diff-block-lines 100000 \
{{ a }} {{ b }}
diff-python-json a b:
diffoscope \
--html build/diff.html \
--exclude 'python/build/**' \
--exclude 'python/install/**' \
--max-diff-block-lines 100000 \
--max-page-diff-block-lines 100000 \
{{ a }} {{ b }}
cat-python-json archive:
tar -x --to-stdout -f {{ archive }} python/PYTHON.json
# Download release artifacts from GitHub Actions
release-download-distributions token commit:
mkdir -p dist
cargo run --release -- fetch-release-distributions --token {{token}} --commit {{commit}} --dest dist --org fox-it --repo python-build-pystandalone
# Upload release artifacts to a GitHub release.
release-upload-distributions token datetime tag:
cargo run --release -- upload-release-distributions --token {{token}} --datetime {{datetime}} --tag {{tag}} --dist dist --org fox-it --repo python-build-pystandalone
# "Upload" release artifacts to a GitHub release in dry-run mode (skip upload).
release-upload-distributions-dry-run token datetime tag:
cargo run --release -- upload-release-distributions --token {{token}} --datetime {{datetime}} --tag {{tag}} --dist dist --org fox-it --repo python-build-pystandalone -n
# Promote a tag to "latest" by pushing to the `latest-release` branch.
release-set-latest-release tag:
#!/usr/bin/env bash
set -euxo pipefail
git fetch origin
git switch latest-release
git reset --hard origin/latest-release
cat << EOF > latest-release.json
{
"version": 1,
"tag": "{{tag}}",
"release_url": "https://github.com/fox-it/python-build-pystandalone/releases/tag/{{tag}}",
"asset_url_prefix": "https://github.com/fox-it/python-build-pystandalone/releases/download/{{tag}}"
}
EOF
# If the branch is dirty, we add and commit.
if ! git diff --quiet; then
git add latest-release.json
git commit -m 'set latest release to {{tag}}'
git push origin latest-release
else
echo "No changes to commit."
fi
git switch main
# Create a GitHub release object, or reuse an existing prerelease.
release-create tag:
#!/usr/bin/env bash
set -euo pipefail
prerelease_exists=$(gh release view {{tag}} --json isPrerelease -t '{{{{.isPrerelease}}' 2>&1 || true)
case "$prerelease_exists" in
true)
echo "note: updating existing prerelease {{tag}}"
;;
false)
echo "error: release {{tag}} already exists"
exit 1
;;
"release not found")
gh release create {{tag}} --prerelease --notes TBD --verify-tag
;;
*)
echo "error: unexpected gh cli output: $prerelease_exists"
exit 1
;;
esac
# Upload release artifacts to an S3-compatible mirror bucket with the correct release names.
# AWS credentials are read from the standard AWS_* environment variables.
# Requires `release-run` to have been run.
release-upload-mirror bucket prefix tag:
#!/bin/bash
set -eo pipefail
datetime=$(ls dist/cpython-3.10.*-x86_64-unknown-linux-gnu-install_only-*.tar.gz | awk -F- '{print $8}' | awk -F. '{print $1}')
cargo run --release -- upload-mirror-distributions \
--dist dist \
--datetime ${datetime} \
--tag {{tag}} \
--bucket {{bucket}} \
--prefix {{prefix}}
# Perform the release job. Assumes that the GitHub Release has been created.
release-run token commit tag:
#!/bin/bash
set -eo pipefail
rm -rf dist
just release-download-distributions {{token}} {{commit}}
datetime=$(ls dist/cpython-3.10.*-x86_64-unknown-linux-gnu-install_only-*.tar.gz | awk -F- '{print $8}' | awk -F. '{print $1}')
just release-upload-distributions {{token}} ${datetime} {{tag}}
just release-set-latest-release {{tag}}
# Perform a release in dry-run mode.
release-dry-run token commit tag:
#!/bin/bash
set -eo pipefail
rm -rf dist
just release-download-distributions {{token}} {{commit}}
datetime=$(ls dist/cpython-3.10.*-x86_64-unknown-linux-gnu-install_only-*.tar.gz | awk -F- '{print $8}' | awk -F. '{print $1}')
just release-upload-distributions-dry-run {{token}} ${datetime} {{tag}}