Skip to content

Commit cc55d9d

Browse files
Speed up workflow validation and releases (#11)
## Summary - avoid duplicate package builds during release validation - download pinned actionlint binary instead of building from source - use cache action v5 and remove redundant pip upgrades - let release validation and build jobs run in parallel before publishing ## Test plan - /opt/homebrew/bin/actionlint - git diff --check -- .github/workflows/release.yml .github/workflows/validate.yml --------- Co-authored-by: Amp <amp@ampcode.com>
1 parent b87364e commit cc55d9d

4 files changed

Lines changed: 50 additions & 30 deletions

File tree

.github/workflows/release.yml

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ jobs:
2828
uses: ./.github/workflows/validate.yml
2929
with:
3030
ref: ${{ github.event.inputs.tag || github.ref }}
31+
build-package: false
3132

3233
wheel:
3334
name: Build wheel
34-
needs: validate
3535
runs-on: ubuntu-24.04
3636
env:
3737
IMPORT_NAME: src_py_lib
@@ -53,17 +53,15 @@ jobs:
5353
cache: pip
5454

5555
- name: Cache uv
56-
uses: actions/cache@v4
56+
uses: actions/cache@v5
5757
with:
5858
path: ~/.cache/uv
5959
key: uv-${{ runner.os }}-py${{ env.PYTHON_VERSION }}-${{ hashFiles('uv.lock') }}
6060
restore-keys: |
6161
uv-${{ runner.os }}-py${{ env.PYTHON_VERSION }}-
6262
6363
- name: Install build tools
64-
run: |
65-
python -m pip install --upgrade pip
66-
python -m pip install "uv==${UV_VERSION}"
64+
run: python -m pip install "uv==${UV_VERSION}"
6765

6866
- name: Validate release inputs
6967
id: release
@@ -145,7 +143,6 @@ jobs:
145143
run: |
146144
python -m venv build/release/install-venv
147145
. build/release/install-venv/bin/activate
148-
python -m pip install --upgrade pip
149146
python -m pip install "${{ steps.build.outputs.wheel_path }}"
150147
python - <<'PY'
151148
import os
@@ -213,22 +210,34 @@ jobs:
213210
${{ steps.build.outputs.wheel_path }}
214211
${{ steps.build.outputs.source_distribution_path }}
215212
213+
github-release:
214+
name: Publish GitHub release assets
215+
needs: [validate, wheel]
216+
runs-on: ubuntu-24.04
217+
218+
steps:
219+
- name: Download release assets
220+
uses: actions/download-artifact@v7
221+
with:
222+
name: src-py-lib-release
223+
path: release-assets
224+
216225
- name: Publish GitHub release assets
217226
env:
218227
GH_TOKEN: ${{ github.token }}
219228
run: |
220-
release_tag="${{ steps.release.outputs.tag }}"
221-
wheel_path="${{ steps.build.outputs.wheel_path }}"
222-
source_distribution_path="${{ steps.build.outputs.source_distribution_path }}"
223-
wheel_checksum_path="${{ steps.build.outputs.wheel_checksum_path }}"
224-
source_distribution_checksum_path="${{ steps.build.outputs.source_distribution_checksum_path }}"
225-
notes_path="${{ steps.notes.outputs.path }}"
226-
release_assets=(
227-
"${wheel_path}"
228-
"${source_distribution_path}"
229-
"${wheel_checksum_path}"
230-
"${source_distribution_checksum_path}"
231-
)
229+
release_tag="${{ github.event.inputs.tag || github.ref_name }}"
230+
notes_path="$(find release-assets -name release-notes.md -print -quit)"
231+
mapfile -t release_assets < <(find release-assets -type f ! -name release-notes.md | sort)
232+
233+
if [[ -z "${notes_path}" ]]; then
234+
echo "::error title=Missing release notes::release-notes.md was not found in release artifact."
235+
exit 1
236+
fi
237+
if [[ "${#release_assets[@]}" -eq 0 ]]; then
238+
echo "::error title=Missing release assets::No release assets were downloaded."
239+
exit 1
240+
fi
232241
233242
if gh release view "${release_tag}" >/dev/null 2>&1; then
234243
gh release edit "${release_tag}" --title "${release_tag}" --notes-file "${notes_path}"
@@ -243,7 +252,7 @@ jobs:
243252
244253
pypi:
245254
name: Publish PyPI package
246-
needs: wheel
255+
needs: [validate, wheel]
247256
runs-on: ubuntu-24.04
248257
permissions:
249258
contents: read

.github/workflows/validate.yml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ on:
77
description: "Git ref to validate. Defaults to the caller's ref."
88
required: false
99
type: string
10+
build-package:
11+
description: "Build and smoke-test package artifacts. Release builds do this separately."
12+
required: false
13+
type: boolean
14+
default: true
1015

1116
permissions:
1217
contents: read
@@ -35,7 +40,7 @@ jobs:
3540

3641
- name: Cache actionlint
3742
id: cache-actionlint
38-
uses: actions/cache@v4
43+
uses: actions/cache@v5
3944
with:
4045
path: ~/.local/bin/actionlint
4146
key: actionlint-${{ runner.os }}-${{ runner.arch }}-${{ env.ACTIONLINT_VERSION }}
@@ -44,15 +49,22 @@ jobs:
4449
if: steps.cache-actionlint.outputs.cache-hit != 'true'
4550
run: |
4651
mkdir -p "${HOME}/.local/bin"
47-
go install "github.com/rhysd/actionlint/cmd/actionlint@v${ACTIONLINT_VERSION}"
48-
install -m 0755 "${HOME}/go/bin/actionlint" "${HOME}/.local/bin/actionlint"
52+
asset="actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz"
53+
checksums="actionlint_${ACTIONLINT_VERSION}_checksums.txt"
54+
base_url="https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}"
55+
56+
curl -fsSLO "${base_url}/${asset}"
57+
curl -fsSLO "${base_url}/${checksums}"
58+
grep " ${asset}$" "${checksums}" | sha256sum --check
59+
tar -xzf "${asset}" -C "${HOME}/.local/bin" actionlint
60+
chmod 0755 "${HOME}/.local/bin/actionlint"
4961
5062
- name: Lint GitHub Actions
5163
run: |
5264
"${HOME}/.local/bin/actionlint"
5365
5466
- name: Cache npm
55-
uses: actions/cache@v4
67+
uses: actions/cache@v5
5668
with:
5769
path: ~/.npm
5870
key: npm-${{ runner.os }}-markdownlint-cli2-${{ env.MARKDOWNLINT_CLI2_VERSION }}
@@ -67,17 +79,15 @@ jobs:
6779
cache: pip
6880

6981
- name: Cache uv
70-
uses: actions/cache@v4
82+
uses: actions/cache@v5
7183
with:
7284
path: ~/.cache/uv
7385
key: uv-${{ runner.os }}-py${{ env.PYTHON_VERSION }}-${{ hashFiles('uv.lock') }}
7486
restore-keys: |
7587
uv-${{ runner.os }}-py${{ env.PYTHON_VERSION }}-
7688
7789
- name: Install uv
78-
run: |
79-
python -m pip install --upgrade pip
80-
python -m pip install "uv==${UV_VERSION}"
90+
run: python -m pip install "uv==${UV_VERSION}"
8191

8292
- name: Validate lockfile
8393
run: uv lock --check
@@ -106,13 +116,14 @@ jobs:
106116
PY
107117
108118
- name: Build wheel
119+
if: inputs.build-package
109120
run: uv build --wheel --out-dir dist --no-create-gitignore
110121

111122
- name: Smoke test installed wheel
123+
if: inputs.build-package
112124
run: |
113125
python -m venv build/ci-venv
114126
. build/ci-venv/bin/activate
115-
python -m pip install --upgrade pip
116127
python -m pip install dist/*.whl
117128
python - <<'PY'
118129
import os

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dev = [
1010

1111
[project]
1212
name = "src-py-lib"
13-
version = "0.1.2"
13+
version = "0.1.3"
1414
description = "Reusable libraries for Sourcegraph projects"
1515
readme = "README.md"
1616
requires-python = ">=3.11"

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)