feat: automate Scoop stable releases (#2517)
This commit is contained in:
@@ -12,6 +12,7 @@ REPO_ROOT = Path(__file__).resolve().parents[2]
|
||||
WORKFLOW_PATH = REPO_ROOT / ".github" / "workflows" / "release.yml"
|
||||
DIAGNOSTICS_PATH = REPO_ROOT / ".github" / "scripts" / "collect-macos-desktop-diagnostics.sh"
|
||||
PUBLISH_NPM_PATH = REPO_ROOT / "scripts" / "release" / "publish-npm.sh"
|
||||
UPDATE_SCOOP_BUCKET_PATH = REPO_ROOT / "scripts" / "release" / "update-scoop-bucket.sh"
|
||||
NPM_PACKAGES_PATH = REPO_ROOT / "scripts" / "release" / "npm-packages.sh"
|
||||
PUBLIC_KEY_PATH = REPO_ROOT / ".github" / "release-signing-key.asc"
|
||||
RELEASE_PROCESS_PATH = REPO_ROOT / "docs" / "public" / "release-process.md"
|
||||
@@ -19,6 +20,7 @@ LINT_WORKFLOW_PATH = REPO_ROOT / ".github" / "workflows" / "lint-action-pinning.
|
||||
WORKFLOW = WORKFLOW_PATH.read_text()
|
||||
DIAGNOSTICS = DIAGNOSTICS_PATH.read_text()
|
||||
PUBLISH_NPM = PUBLISH_NPM_PATH.read_text()
|
||||
UPDATE_SCOOP_BUCKET = UPDATE_SCOOP_BUCKET_PATH.read_text()
|
||||
NPM_PACKAGES = NPM_PACKAGES_PATH.read_text()
|
||||
RELEASE_PROCESS = RELEASE_PROCESS_PATH.read_text()
|
||||
LINT_WORKFLOW = LINT_WORKFLOW_PATH.read_text()
|
||||
@@ -152,6 +154,7 @@ class ReleaseWorkflowContractTest(unittest.TestCase):
|
||||
"publish-release",
|
||||
"publish-npm",
|
||||
"update-homebrew-tap",
|
||||
"update-scoop-bucket",
|
||||
):
|
||||
block = job_block(name)
|
||||
self.assertIn("github.event_name == 'workflow_dispatch'", block)
|
||||
@@ -196,6 +199,7 @@ class ReleaseWorkflowContractTest(unittest.TestCase):
|
||||
),
|
||||
"publish-npm": ("prepare", "publish-release"),
|
||||
"update-homebrew-tap": ("prepare", "publish-release"),
|
||||
"update-scoop-bucket": ("prepare", "publish-release"),
|
||||
}
|
||||
|
||||
for name, dependencies in direct_dependencies.items():
|
||||
@@ -255,6 +259,30 @@ class ReleaseWorkflowContractTest(unittest.TestCase):
|
||||
self.assertIn('CLI_PACKAGE_BACKUP="$WORK_DIR/cli-package.json"', PUBLISH_NPM)
|
||||
self.assertIn('cp "$CLI_PACKAGE_BACKUP" "$CLI_PACKAGE_JSON"', PUBLISH_NPM)
|
||||
|
||||
def test_scoop_publication_uses_current_control_revision_and_deploy_key(self) -> None:
|
||||
scoop = job_block("update-scoop-bucket")
|
||||
self.assertIn("needs: [prepare, publish-release]", scoop)
|
||||
self.assertIn("ref: ${{ github.workflow_sha }}", scoop)
|
||||
self.assertIn("GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}", scoop)
|
||||
self.assertIn(
|
||||
"SCOOP_BUCKET_DEPLOY_KEY: ${{ secrets.SCOOP_BUCKET_DEPLOY_KEY }}",
|
||||
scoop,
|
||||
)
|
||||
self.assertIn("bash scripts/release/update-scoop-bucket.sh", scoop)
|
||||
self.assertIn('"${{ needs.prepare.outputs.version }}"', scoop)
|
||||
self.assertIn('"${{ needs.prepare.outputs.tag }}"', scoop)
|
||||
self.assertIn("!inputs.dry_run", scoop)
|
||||
self.assertIn("!inputs.desktop_validation_only", scoop)
|
||||
self.assertNotIn("inputs.backfill_tag == ''", scoop)
|
||||
|
||||
preflight = step_block("Require Scoop bucket deploy key")
|
||||
self.assertIn('if [ -z "$SCOOP_BUCKET_DEPLOY_KEY" ]', preflight)
|
||||
self.assertIn("SCOOP_BUCKET_DEPLOY_KEY is required", preflight)
|
||||
|
||||
self.assertIn("SCOOP_BUCKET_DEPLOY_KEY", UPDATE_SCOOP_BUCKET)
|
||||
self.assertIn("git push origin HEAD:main", UPDATE_SCOOP_BUCKET)
|
||||
self.assertIn('CHECKSUM_NAME="${ARCHIVE_NAME}.sha256"', UPDATE_SCOOP_BUCKET)
|
||||
|
||||
def test_publish_npm_rejects_version_dist_tag_mismatches(self) -> None:
|
||||
cases = (
|
||||
(
|
||||
@@ -492,7 +520,8 @@ class ReleaseWorkflowContractTest(unittest.TestCase):
|
||||
"node --test scripts/release/nightly-version.test.mjs "
|
||||
"scripts/release/nightly-release.test.mjs "
|
||||
"scripts/release/npm-view-version.test.mjs "
|
||||
"scripts/release/publish-npm.test.mjs",
|
||||
"scripts/release/publish-npm.test.mjs "
|
||||
"scripts/release/update-scoop-bucket.test.mjs",
|
||||
LINT_WORKFLOW,
|
||||
)
|
||||
|
||||
@@ -566,6 +595,7 @@ class ReleaseWorkflowContractTest(unittest.TestCase):
|
||||
"publish-release",
|
||||
"publish-npm",
|
||||
"update-homebrew-tap",
|
||||
"update-scoop-bucket",
|
||||
):
|
||||
block = job_block(name)
|
||||
self.assertRegex(
|
||||
|
||||
@@ -71,7 +71,7 @@ jobs:
|
||||
run: bash scripts/release/retry-ghcr-command.test.sh
|
||||
|
||||
- name: Test npm release helpers
|
||||
run: node --test scripts/release/nightly-version.test.mjs scripts/release/nightly-release.test.mjs scripts/release/npm-view-version.test.mjs scripts/release/publish-npm.test.mjs
|
||||
run: node --test scripts/release/nightly-version.test.mjs scripts/release/nightly-release.test.mjs scripts/release/npm-view-version.test.mjs scripts/release/publish-npm.test.mjs scripts/release/update-scoop-bucket.test.mjs
|
||||
|
||||
- name: Verify action refs
|
||||
run: python3 .github/scripts/lint-action-pinning.py
|
||||
|
||||
@@ -19,6 +19,7 @@ name: release
|
||||
# 9. publish-release — create GH release with runtime + desktop assets and release notes
|
||||
# 10. publish-npm — publish kandev@X.Y.Z + @kdlbs/runtime-*@X.Y.Z to npmjs
|
||||
# 11. update-homebrew-tap — push updated Formula/kandev.rb to kdlbs/homebrew-kandev
|
||||
# 12. update-scoop-bucket — push updated bucket/kandev.json to kdlbs/scoop-kandev
|
||||
#
|
||||
# npm publishing uses Trusted Publishers (OIDC) — no NPM_TOKEN required.
|
||||
# Each package (kandev + 5 @kdlbs/runtime-* packages) must have this workflow
|
||||
@@ -26,6 +27,7 @@ name: release
|
||||
#
|
||||
# Required repository secret for public releases:
|
||||
# HOMEBREW_TAP_DEPLOY_KEY — SSH private key for kdlbs/homebrew-kandev deploy key
|
||||
# SCOOP_BUCKET_DEPLOY_KEY — SSH private key for kdlbs/scoop-kandev deploy key
|
||||
# Required configuration in the `release` environment:
|
||||
# RELEASE_GPG_PRIVATE_KEY — secret containing the ASCII-armored release tag signing key
|
||||
# RELEASE_GPG_FINGERPRINT — variable containing the key's full fingerprint
|
||||
@@ -2157,3 +2159,45 @@ jobs:
|
||||
bash scripts/release/update-homebrew-tap.sh \
|
||||
"${{ needs.prepare.outputs.version }}" \
|
||||
"${{ needs.prepare.outputs.tag }}"
|
||||
|
||||
update-scoop-bucket:
|
||||
name: Update Scoop bucket
|
||||
needs: [prepare, publish-release]
|
||||
if: >-
|
||||
${{ !cancelled() &&
|
||||
github.event_name == 'workflow_dispatch' &&
|
||||
inputs.channel == 'stable' &&
|
||||
!inputs.dry_run &&
|
||||
!inputs.desktop_validation_only &&
|
||||
needs.prepare.result == 'success' &&
|
||||
needs.publish-release.result == 'success'
|
||||
}}
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||
with:
|
||||
# Backfill application artifacts come from the selected tag, but the
|
||||
# publication helper must come from the current workflow revision.
|
||||
ref: ${{ github.workflow_sha }}
|
||||
persist-credentials: false
|
||||
|
||||
- name: Require Scoop bucket deploy key
|
||||
env:
|
||||
SCOOP_BUCKET_DEPLOY_KEY: ${{ secrets.SCOOP_BUCKET_DEPLOY_KEY }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ -z "$SCOOP_BUCKET_DEPLOY_KEY" ]; then
|
||||
echo "::error::SCOOP_BUCKET_DEPLOY_KEY is required to publish the Scoop bucket." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Update Scoop bucket
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
SCOOP_BUCKET_DEPLOY_KEY: ${{ secrets.SCOOP_BUCKET_DEPLOY_KEY }}
|
||||
run: |
|
||||
bash scripts/release/update-scoop-bucket.sh \
|
||||
"${{ needs.prepare.outputs.version }}" \
|
||||
"${{ needs.prepare.outputs.tag }}"
|
||||
|
||||
Reference in New Issue
Block a user