|
25 | 25 | build: |
26 | 26 | runs-on: ubuntu-24.04-riscv |
27 | 27 | env: |
28 | | - CPYTHON_TAG: ${{ inputs.cpython_tag }} |
29 | | - FREETHREADED: ${{ inputs.freethreaded }} |
30 | 28 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
31 | 29 | steps: |
32 | 30 | - name: Checkout this repo |
@@ -66,109 +64,103 @@ jobs: |
66 | 64 | - name: Compute normalised version |
67 | 65 | id: vars |
68 | 66 | run: | |
69 | | - tag="$CPYTHON_TAG" |
| 67 | + # Make sure tag starts by v* |
| 68 | + tag="${{ inputs.cpython_tag }}" |
| 69 | + tag="${tag#v}" |
| 70 | + tag="v${tag}" |
70 | 71 | # Strip leading v, expand a/b/rc suffixes |
71 | 72 | normalised="${tag#v}" |
72 | 73 | normalised="$(echo "$normalised" | sed -E 's/a([0-9]+)$/-alpha.\1/; s/b([0-9]+)$/-beta.\1/; s/rc([0-9]+)$/-rc.\1/')" |
73 | 74 | # X.Y |
74 | 75 | minor_num="$(echo "$normalised" | cut -d. -f2)" |
75 | 76 | minor="3.${minor_num}" |
| 77 | + echo "tag=${tag}" >> "$GITHUB_OUTPUT" |
76 | 78 | echo "normalised=${normalised}" >> "$GITHUB_OUTPUT" |
77 | 79 | echo "minor=${minor}" >> "$GITHUB_OUTPUT" |
78 | 80 | echo "minor_num=${minor_num}" >> "$GITHUB_OUTPUT" |
79 | 81 | echo "archive_base=python-${normalised}-linux-24.04-riscv64" >> "$GITHUB_OUTPUT" |
80 | 82 | echo "Normalised version: ${normalised}" |
81 | 83 | echo "Python X.Y: ${minor}" |
82 | | - if [ "${FREETHREADED}" = "true" ] && [ "${minor_num}" -lt 13 ]; then |
| 84 | + if [ "${{ inputs.freethreaded }}" = "true" ] && [ "${minor_num}" -lt 13 ]; then |
83 | 85 | echo "ERROR: freethreaded build requires CPython 3.13+" >&2 |
84 | 86 | exit 1 |
85 | 87 | fi |
86 | 88 |
|
87 | 89 | - name: Checkout CPython |
88 | | - run: git clone --depth 1 --branch "$CPYTHON_TAG" https://github.com/python/cpython.git src |
| 90 | + run: git clone --depth 1 --branch "${{ steps.vars.outputs.tag }}" https://github.com/python/cpython.git src |
89 | 91 |
|
90 | 92 | - name: Build standard CPython |
91 | | - env: |
92 | | - MINOR: ${{ steps.vars.outputs.minor }} |
93 | | - ARCHIVE_BASE: ${{ steps.vars.outputs.archive_base }} |
94 | | - NORMALISED: ${{ steps.vars.outputs.normalised }} |
95 | 93 | run: | |
96 | 94 | mkdir -p output |
97 | 95 | pushd src |
98 | | - ./configure --prefix=/opt/hostedtoolcache/Python/${NORMALISED}/riscv64 --with-ensurepip=install --enable-shared |
| 96 | + ./configure --prefix=/opt/hostedtoolcache/Python/${{ steps.vars.outputs.normalised }}/riscv64 --with-ensurepip=install --enable-shared |
99 | 97 | make -j"$(nproc)" 2>&1 | tee ../build_output.txt |
100 | 98 | make install DESTDIR="$PWD/../staging-std" |
101 | 99 | popd |
102 | 100 |
|
103 | | - mkdir -p "$ARCHIVE_BASE" |
104 | | - cp -a staging-std/usr/local/bin "$ARCHIVE_BASE/" |
105 | | - cp -a staging-std/usr/local/include "$ARCHIVE_BASE/" |
106 | | - cp -a staging-std/usr/local/lib "$ARCHIVE_BASE/" |
107 | | - cp -a staging-std/usr/local/share "$ARCHIVE_BASE/" |
| 101 | + mkdir -p "${{ steps.vars.outputs.archive_base }}" |
| 102 | + cp -a staging-std/usr/local/bin "${{ steps.vars.outputs.archive_base }}/" |
| 103 | + cp -a staging-std/usr/local/include "${{ steps.vars.outputs.archive_base }}/" |
| 104 | + cp -a staging-std/usr/local/lib "${{ steps.vars.outputs.archive_base }}/" |
| 105 | + cp -a staging-std/usr/local/share "${{ steps.vars.outputs.archive_base }}/" |
108 | 106 |
|
109 | | - ln -srf "$ARCHIVE_BASE/bin/python${MINOR}" "$ARCHIVE_BASE/bin/python" |
110 | | - ln -srf "$ARCHIVE_BASE/bin/pip${MINOR}" "$ARCHIVE_BASE/bin/pip" |
| 107 | + ln -srf "${{ steps.vars.outputs.archive_base }}/bin/python${{ steps.vars.outputs.minor }}" "${{ steps.vars.outputs.archive_base }}/bin/python" |
| 108 | + ln -srf "${{ steps.vars.outputs.archive_base }}/bin/pip${{ steps.vars.outputs.minor }}" "${{ steps.vars.outputs.archive_base }}/bin/pip" |
111 | 109 |
|
112 | | - sed -e "s|{{__VERSION_FULL__}}|${NORMALISED}|g" \ |
| 110 | + sed -e "s|{{__VERSION_FULL__}}|${{ steps.vars.outputs.normalised }}|g" \ |
113 | 111 | -e "s|{{__ARCH__}}|riscv64|g" \ |
114 | | - installers/nix-setup-template.sh > "$ARCHIVE_BASE/setup.sh" |
| 112 | + installers/nix-setup-template.sh > "${{ steps.vars.outputs.archive_base }}/setup.sh" |
115 | 113 |
|
116 | | - chmod +x "$ARCHIVE_BASE/setup.sh" |
| 114 | + chmod +x "${{ steps.vars.outputs.archive_base }}/setup.sh" |
117 | 115 |
|
118 | | - mv build_output.txt "$ARCHIVE_BASE/build_output.txt" |
| 116 | + mv build_output.txt "${{ steps.vars.outputs.archive_base }}/build_output.txt" |
119 | 117 |
|
120 | | - (cd "$ARCHIVE_BASE" && find . \( -type f -o -type l \) | sed 's|^\./|/|') > "$ARCHIVE_BASE/tools_structure.txt" |
| 118 | + (cd "${{ steps.vars.outputs.archive_base }}" && find . \( -type f -o -type l \) | sed 's|^\./|/|') > "${{ steps.vars.outputs.archive_base }}/tools_structure.txt" |
121 | 119 |
|
122 | | - tar -czf "output/${ARCHIVE_BASE}.tar.gz" -C "$ARCHIVE_BASE" . |
123 | | - rm -rf "$ARCHIVE_BASE" staging-std |
| 120 | + tar -czf "output/${{ steps.vars.outputs.archive_base }}.tar.gz" -C "${{ steps.vars.outputs.archive_base }}" . |
| 121 | + rm -rf "${{ steps.vars.outputs.archive_base }}" staging-std |
124 | 122 |
|
125 | 123 | - name: Build free-threaded CPython |
126 | 124 | if: ${{ inputs.freethreaded == true }} |
127 | | - env: |
128 | | - MINOR: ${{ steps.vars.outputs.minor }} |
129 | | - ARCHIVE_BASE: ${{ format('{0}-freethreaded', steps.vars.outputs.archive_base) }} |
130 | | - NORMALISED: ${{ steps.vars.outputs.normalised }} |
131 | 125 | run: | |
132 | 126 | pushd src |
133 | 127 | git clean -fdx |
134 | | - ./configure --prefix=/opt/hostedtoolcache/Python/${NORMALISED}/riscv64-freethreaded --with-ensurepip=install --enable-shared --disable-gil |
| 128 | + ./configure --prefix=/opt/hostedtoolcache/Python/${{ steps.vars.outputs.normalised }}/riscv64-freethreaded --with-ensurepip=install --enable-shared --disable-gil |
135 | 129 | make -j"$(nproc)" 2>&1 | tee ../build_output.txt |
136 | 130 | make install DESTDIR="$PWD/../staging-ft" |
137 | 131 | popd |
138 | 132 |
|
139 | | - mkdir -p "$ARCHIVE_BASE" |
140 | | - cp -a staging-ft/usr/local/bin "$ARCHIVE_BASE/" |
141 | | - cp -a staging-ft/usr/local/include "$ARCHIVE_BASE/" |
142 | | - cp -a staging-ft/usr/local/lib "$ARCHIVE_BASE/" |
143 | | - cp -a staging-ft/usr/local/share "$ARCHIVE_BASE/" |
| 133 | + mkdir -p "${{ steps.vars.outputs.archive_base }}-freethreaded" |
| 134 | + cp -a staging-ft/usr/local/bin "${{ steps.vars.outputs.archive_base }}-freethreaded/" |
| 135 | + cp -a staging-ft/usr/local/include "${{ steps.vars.outputs.archive_base }}-freethreaded/" |
| 136 | + cp -a staging-ft/usr/local/lib "${{ steps.vars.outputs.archive_base }}-freethreaded/" |
| 137 | + cp -a staging-ft/usr/local/share "${{ steps.vars.outputs.archive_base }}-freethreaded/" |
144 | 138 |
|
145 | | - ln -srf "$ARCHIVE_BASE/bin/python${MINOR}" "$ARCHIVE_BASE/bin/python" |
146 | | - ln -srf "$ARCHIVE_BASE/bin/pip${MINOR}" "$ARCHIVE_BASE/bin/pip" |
| 139 | + ln -srf "${{ steps.vars.outputs.archive_base }}-freethreaded/bin/python${{ steps.vars.outputs.minor }}" "${{ steps.vars.outputs.archive_base }}-freethreaded/bin/python" |
| 140 | + ln -srf "${{ steps.vars.outputs.archive_base }}-freethreaded/bin/pip${{ steps.vars.outputs.minor }}" "${{ steps.vars.outputs.archive_base }}-freethreaded/bin/pip" |
147 | 141 |
|
148 | | - sed -e "s|{{__VERSION_FULL__}}|${NORMALISED}|g" \ |
| 142 | + sed -e "s|{{__VERSION_FULL__}}|${{ steps.vars.outputs.normalised }}|g" \ |
149 | 143 | -e "s|{{__ARCH__}}|riscv64-freethreaded|g" \ |
150 | | - installers/nix-setup-template.sh > "$ARCHIVE_BASE/setup.sh" |
| 144 | + installers/nix-setup-template.sh > "${{ steps.vars.outputs.archive_base }}-freethreaded/setup.sh" |
151 | 145 |
|
152 | | - chmod +x "$ARCHIVE_BASE/setup.sh" |
| 146 | + chmod +x "${{ steps.vars.outputs.archive_base }}-freethreaded/setup.sh" |
153 | 147 |
|
154 | | - mv build_output.txt "$ARCHIVE_BASE/build_output.txt" |
| 148 | + mv build_output.txt "${{ steps.vars.outputs.archive_base }}-freethreaded/build_output.txt" |
155 | 149 |
|
156 | | - (cd "$ARCHIVE_BASE" && find . \( -type f -o -type l \) | sed 's|^\./|/|') > "$ARCHIVE_BASE/tools_structure.txt" |
| 150 | + (cd "${{ steps.vars.outputs.archive_base }}-freethreaded" && find . \( -type f -o -type l \) | sed 's|^\./|/|') > "${{ steps.vars.outputs.archive_base }}-freethreaded/tools_structure.txt" |
157 | 151 |
|
158 | | - tar -czf "output/${ARCHIVE_BASE}.tar.gz" -C "$ARCHIVE_BASE" . |
159 | | - rm -rf "$ARCHIVE_BASE" staging-ft |
| 152 | + tar -czf "output/${{ steps.vars.outputs.archive_base }}-freethreaded.tar.gz" -C "${{ steps.vars.outputs.archive_base }}-freethreaded" . |
| 153 | + rm -rf "${{ steps.vars.outputs.archive_base }}-freethreaded" staging-ft |
160 | 154 |
|
161 | 155 | - name: Print tarball hashes |
162 | 156 | run: sha256sum output/*.tar.gz |
163 | 157 |
|
164 | 158 | - name: Publish release |
165 | | - env: |
166 | | - NORMALISED: ${{ steps.vars.outputs.normalised }} |
167 | 159 | run: | |
168 | | - TAG="${NORMALISED}-${GITHUB_RUN_ID}" |
| 160 | + TAG="${{ steps.vars.outputs.normalised }}-${GITHUB_RUN_ID}" |
169 | 161 | gh release create "$TAG" --repo "$GITHUB_REPOSITORY" \ |
170 | | - --title "$NORMALISED" \ |
171 | | - --notes "Python $NORMALISED" \ |
| 162 | + --title "${{ steps.vars.outputs.normalised }}" \ |
| 163 | + --notes "Python ${{ steps.vars.outputs.normalised }}" \ |
172 | 164 | ./output/*.tar.gz |
173 | 165 |
|
174 | 166 | - name: Trigger manifest refresh |
|
0 commit comments