mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-19 06:26:14 -05:00
ci: Publish snapshot feeds after verified asset publication
This commit is contained in:
7 files changed
+226
-26
No files matched your search
@@ -12,6 +12,9 @@ on:
|
|||||||
channel:
|
channel:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
build:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
builder:
|
builder:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
@@ -85,7 +88,7 @@ jobs:
|
|||||||
- name: Build gpgui in Docker
|
- name: Build gpgui in Docker
|
||||||
env:
|
env:
|
||||||
GPGUI_BUILDER: ${{ inputs.builder }}
|
GPGUI_BUILDER: ${{ inputs.builder }}
|
||||||
GPGUI_BUILD_VERSION: ${{ github.run_number }}.${{ github.run_attempt }}
|
GPGUI_BUILD_VERSION: ${{ inputs.build }}
|
||||||
GPGUI_UPDATE_CHANNEL: ${{ inputs.channel }}
|
GPGUI_UPDATE_CHANNEL: ${{ inputs.channel }}
|
||||||
GPGUI_LICENSE_SIGNING_KEYS: ${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}
|
GPGUI_LICENSE_SIGNING_KEYS: ${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ on:
|
|||||||
channel:
|
channel:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
build:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
secrets:
|
secrets:
|
||||||
GH_PAT:
|
GH_PAT:
|
||||||
required: true
|
required: true
|
||||||
@@ -35,7 +38,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
CARGO_INCREMENTAL: '0'
|
CARGO_INCREMENTAL: '0'
|
||||||
CARGO_BUILD_JOBS: '2'
|
CARGO_BUILD_JOBS: '2'
|
||||||
GPGUI_BUILD_VERSION: ${{ github.run_number }}.${{ github.run_attempt }}
|
GPGUI_BUILD_VERSION: ${{ inputs.build }}
|
||||||
GPGUI_GIT_COMMIT: ${{ inputs.gpgui_ref }}
|
GPGUI_GIT_COMMIT: ${{ inputs.gpgui_ref }}
|
||||||
GPGUI_UPDATE_CHANNEL: ${{ inputs.channel }}
|
GPGUI_UPDATE_CHANNEL: ${{ inputs.channel }}
|
||||||
GPGUI_LICENSE_SIGNING_KEYS: ${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}
|
GPGUI_LICENSE_SIGNING_KEYS: ${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}
|
||||||
|
|||||||
@@ -69,8 +69,10 @@ jobs:
|
|||||||
actions: read
|
actions: read
|
||||||
contents: read
|
contents: read
|
||||||
outputs:
|
outputs:
|
||||||
gp_sha: ${{ steps.sources.outputs.gp_sha }}
|
gp_sha: ${{ steps.identity.outputs.gp_sha }}
|
||||||
gpgui_sha: ${{ steps.sources.outputs.gpgui_sha }}
|
gpgui_sha: ${{ steps.identity.outputs.gpgui_sha }}
|
||||||
|
version: ${{ steps.identity.outputs.version }}
|
||||||
|
build_version: ${{ steps.identity.outputs.build_version }}
|
||||||
steps:
|
steps:
|
||||||
- name: Validate stable refs
|
- name: Validate stable refs
|
||||||
env:
|
env:
|
||||||
@@ -119,11 +121,12 @@ jobs:
|
|||||||
token: ${{ secrets.GH_PAT }}
|
token: ${{ secrets.GH_PAT }}
|
||||||
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gpgui_branch || github.ref_name }}
|
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gpgui_branch || github.ref_name }}
|
||||||
path: selected/gpgui
|
path: selected/gpgui
|
||||||
- name: Record selected sources
|
- name: Record selected sources and versions
|
||||||
id: sources
|
id: identity
|
||||||
run: |
|
run: |
|
||||||
python3 scripts/record-build-sources.py selected-sources/sources.json \
|
python3 scripts/record-build-sources.py selected-sources/sources.json \
|
||||||
--gp selected/gp --gpgui selected/gpgui
|
--gp selected/gp --gpgui selected/gpgui \
|
||||||
|
--build-version "${{ github.run_number }}.${{ github.run_attempt }}"
|
||||||
- name: Retain selected sources for retries
|
- name: Retain selected sources for retries
|
||||||
if: steps.restored.outputs.cached != 'true'
|
if: steps.restored.outputs.cached != 'true'
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v7
|
||||||
@@ -442,6 +445,7 @@ jobs:
|
|||||||
gp_ref: ${{ needs.validate-inputs.outputs.gp_sha }}
|
gp_ref: ${{ needs.validate-inputs.outputs.gp_sha }}
|
||||||
gpgui_ref: ${{ needs.validate-inputs.outputs.gpgui_sha }}
|
gpgui_ref: ${{ needs.validate-inputs.outputs.gpgui_sha }}
|
||||||
channel: ${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }}
|
channel: ${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }}
|
||||||
|
build: ${{ needs.validate-inputs.outputs.build_version }}
|
||||||
builder: gpgui-builder-tauri2
|
builder: gpgui-builder-tauri2
|
||||||
verify_desktop_assets: true
|
verify_desktop_assets: true
|
||||||
secrets:
|
secrets:
|
||||||
@@ -455,6 +459,7 @@ jobs:
|
|||||||
gp_ref: ${{ needs.validate-inputs.outputs.gp_sha }}
|
gp_ref: ${{ needs.validate-inputs.outputs.gp_sha }}
|
||||||
gpgui_ref: ${{ needs.validate-inputs.outputs.gpgui_sha }}
|
gpgui_ref: ${{ needs.validate-inputs.outputs.gpgui_sha }}
|
||||||
channel: ${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }}
|
channel: ${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }}
|
||||||
|
build: ${{ needs.validate-inputs.outputs.build_version }}
|
||||||
builder: gpgui-alpine-builder-tauri2
|
builder: gpgui-alpine-builder-tauri2
|
||||||
artifact_suffix: -musl
|
artifact_suffix: -musl
|
||||||
secrets:
|
secrets:
|
||||||
@@ -467,6 +472,7 @@ jobs:
|
|||||||
gp_ref: ${{ needs.validate-inputs.outputs.gp_sha }}
|
gp_ref: ${{ needs.validate-inputs.outputs.gp_sha }}
|
||||||
gpgui_ref: ${{ needs.validate-inputs.outputs.gpgui_sha }}
|
gpgui_ref: ${{ needs.validate-inputs.outputs.gpgui_sha }}
|
||||||
channel: ${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }}
|
channel: ${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }}
|
||||||
|
build: ${{ needs.validate-inputs.outputs.build_version }}
|
||||||
secrets:
|
secrets:
|
||||||
GH_PAT: ${{ secrets.GH_PAT }}
|
GH_PAT: ${{ secrets.GH_PAT }}
|
||||||
|
|
||||||
@@ -483,7 +489,7 @@ jobs:
|
|||||||
gp_ref: ${{ needs.validate-inputs.outputs.gp_sha }}
|
gp_ref: ${{ needs.validate-inputs.outputs.gp_sha }}
|
||||||
gpgui_ref: ${{ needs.validate-inputs.outputs.gpgui_sha }}
|
gpgui_ref: ${{ needs.validate-inputs.outputs.gpgui_sha }}
|
||||||
channel: ${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }}
|
channel: ${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }}
|
||||||
build: ${{ format('{0}.{1}', github.run_number, github.run_attempt) }}
|
build: ${{ needs.validate-inputs.outputs.build_version }}
|
||||||
secrets:
|
secrets:
|
||||||
GH_PAT: ${{ secrets.GH_PAT }}
|
GH_PAT: ${{ secrets.GH_PAT }}
|
||||||
WINDOWS_UPDATE_PRIVATE_KEY: ${{ secrets.WINDOWS_UPDATE_PRIVATE_KEY }}
|
WINDOWS_UPDATE_PRIVATE_KEY: ${{ secrets.WINDOWS_UPDATE_PRIVATE_KEY }}
|
||||||
@@ -682,7 +688,7 @@ jobs:
|
|||||||
FEED_URL: ${{ vars.SPARKLE_FEED_URL }}
|
FEED_URL: ${{ vars.SPARKLE_FEED_URL }}
|
||||||
CHANNEL: ${{ (github.event_name == 'workflow_dispatch' && inputs.channel || 'stable') }}
|
CHANNEL: ${{ (github.event_name == 'workflow_dispatch' && inputs.channel || 'stable') }}
|
||||||
RELEASE_TAG: ${{ (github.event_name == 'workflow_dispatch' && (inputs.channel == 'stable' && inputs.gp_branch || 'snapshot') || github.ref_name) }}
|
RELEASE_TAG: ${{ (github.event_name == 'workflow_dispatch' && (inputs.channel == 'stable' && inputs.gp_branch || 'snapshot') || github.ref_name) }}
|
||||||
BUILD_VERSION: ${{ format('{0}.{1}', github.run_number, github.run_attempt) }}
|
BUILD_VERSION: ${{ needs.validate-inputs.outputs.build_version }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
@@ -850,7 +856,7 @@ jobs:
|
|||||||
CHANNEL: ${{ (github.event_name == 'workflow_dispatch' && inputs.channel || 'stable') }}
|
CHANNEL: ${{ (github.event_name == 'workflow_dispatch' && inputs.channel || 'stable') }}
|
||||||
RELEASE_TAG: ${{ (github.event_name == 'workflow_dispatch' && (inputs.channel == 'stable' && inputs.gp_branch || 'snapshot') || github.ref_name) }}
|
RELEASE_TAG: ${{ (github.event_name == 'workflow_dispatch' && (inputs.channel == 'stable' && inputs.gp_branch || 'snapshot') || github.ref_name) }}
|
||||||
REQUEST_ID: ${{ format('{0}.{1}.macos', github.run_id, github.run_attempt) }}
|
REQUEST_ID: ${{ format('{0}.{1}.macos', github.run_id, github.run_attempt) }}
|
||||||
BUILD_VERSION: ${{ format('{0}.{1}', github.run_number, github.run_attempt) }}
|
BUILD_VERSION: ${{ needs.validate-inputs.outputs.build_version }}
|
||||||
WORKFLOW_SHA: ${{ github.sha }}
|
WORKFLOW_SHA: ${{ github.sha }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
@@ -1057,7 +1063,7 @@ jobs:
|
|||||||
exec 3>&1
|
exec 3>&1
|
||||||
(
|
(
|
||||||
set -eu
|
set -eu
|
||||||
export GPGUI_BUILD_VERSION=${{ github.run_number }}.${{ github.run_attempt }}
|
export GPGUI_BUILD_VERSION=${{ needs.validate-inputs.outputs.build_version }}
|
||||||
export GPGUI_UPDATE_CHANNEL=${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }}
|
export GPGUI_UPDATE_CHANNEL=${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }}
|
||||||
export GPGUI_LICENSE_SIGNING_KEYS='${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}'
|
export GPGUI_LICENSE_SIGNING_KEYS='${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}'
|
||||||
|
|
||||||
@@ -1141,7 +1147,7 @@ jobs:
|
|||||||
set -eu
|
set -eu
|
||||||
export AUTOCONF_VERSION=2.72
|
export AUTOCONF_VERSION=2.72
|
||||||
export AUTOMAKE_VERSION=1.17
|
export AUTOMAKE_VERSION=1.17
|
||||||
export GPGUI_BUILD_VERSION=${{ github.run_number }}.${{ github.run_attempt }}
|
export GPGUI_BUILD_VERSION=${{ needs.validate-inputs.outputs.build_version }}
|
||||||
export GPGUI_UPDATE_CHANNEL=${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }}
|
export GPGUI_UPDATE_CHANNEL=${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }}
|
||||||
export GPGUI_LICENSE_SIGNING_KEYS='${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}'
|
export GPGUI_LICENSE_SIGNING_KEYS='${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}'
|
||||||
|
|
||||||
@@ -1312,6 +1318,61 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cd gh-release/gp/scripts && ./gh-release.sh "$RELEASE_TAG"
|
cd gh-release/gp/scripts && ./gh-release.sh "$RELEASE_TAG"
|
||||||
|
|
||||||
|
publish-macos-assets:
|
||||||
|
needs: [build-macos, gh-release]
|
||||||
|
if: >-
|
||||||
|
${{ !cancelled() &&
|
||||||
|
needs.build-macos.result == 'success' && needs.gh-release.result == 'success' }}
|
||||||
|
permissions:
|
||||||
|
actions: read
|
||||||
|
contents: write
|
||||||
|
uses: ./.github/workflows/publish-macos-assets.yaml
|
||||||
|
with:
|
||||||
|
build_run_id: ${{ github.run_id }}
|
||||||
|
release_tag: ${{ github.event_name == 'workflow_dispatch' && (inputs.channel == 'stable' && inputs.gp_branch || 'snapshot') || github.ref_name }}
|
||||||
|
expected_gui: ${{ github.event_name == 'workflow_dispatch' && inputs.macos_gui || 'nsh' }}
|
||||||
|
secrets: inherit
|
||||||
|
|
||||||
|
publish-windows-snapshot-feed:
|
||||||
|
needs: [validate-inputs, gh-release, publish-macos-assets]
|
||||||
|
if: >-
|
||||||
|
${{ !cancelled() && github.event_name == 'workflow_dispatch' &&
|
||||||
|
inputs.channel == 'snapshot' && !inputs.build_only && inputs.build_windows &&
|
||||||
|
needs.gh-release.result == 'success' &&
|
||||||
|
(!inputs.build_macos || needs.publish-macos-assets.result == 'success') }}
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
uses: ./.github/workflows/publish-windows-update-feed.yaml
|
||||||
|
with:
|
||||||
|
gpgui_ref: ${{ needs.validate-inputs.outputs.gpgui_sha }}
|
||||||
|
release_tag: snapshot
|
||||||
|
version: ${{ needs.validate-inputs.outputs.version }}
|
||||||
|
channel: snapshot
|
||||||
|
build: ${{ needs.validate-inputs.outputs.build_version }}
|
||||||
|
highlights: Development snapshot.
|
||||||
|
secrets: inherit
|
||||||
|
|
||||||
|
publish-macos-unix-snapshot-feeds:
|
||||||
|
needs: [validate-inputs, gh-release, publish-macos-assets, publish-windows-snapshot-feed]
|
||||||
|
if: >-
|
||||||
|
${{ !cancelled() && github.event_name == 'workflow_dispatch' &&
|
||||||
|
inputs.channel == 'snapshot' && !inputs.build_only && inputs.build_macos &&
|
||||||
|
needs.gh-release.result == 'success' && needs.publish-macos-assets.result == 'success' &&
|
||||||
|
(!inputs.build_windows || needs.publish-windows-snapshot-feed.result == 'success') }}
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
uses: ./.github/workflows/publish-update-feeds.yaml
|
||||||
|
with:
|
||||||
|
gpgui_ref: ${{ needs.validate-inputs.outputs.gpgui_sha }}
|
||||||
|
gp_ref: ${{ needs.validate-inputs.outputs.gp_sha }}
|
||||||
|
channel: snapshot
|
||||||
|
release_tag: snapshot
|
||||||
|
archive_name: ${{ format('GPConnect_{0}-snapshot.{1}_arm64.zip', needs.validate-inputs.outputs.version, needs.validate-inputs.outputs.build_version) }}
|
||||||
|
expected_gui: ${{ inputs.macos_gui }}
|
||||||
|
unix_platforms: ${{ (inputs.build_bsd || inputs.build_bsd_arm64) && 'linux,freebsd,openbsd' || 'linux' }}
|
||||||
|
highlights: Development snapshot.
|
||||||
|
secrets: inherit
|
||||||
|
|
||||||
publish-docker-image:
|
publish-docker-image:
|
||||||
needs:
|
needs:
|
||||||
- validate-inputs
|
- validate-inputs
|
||||||
|
|||||||
@@ -1,6 +1,21 @@
|
|||||||
name: Publish macOS assets
|
name: Publish macOS assets
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
build_run_id:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
release_tag:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
expected_gui:
|
||||||
|
required: false
|
||||||
|
default: nsh
|
||||||
|
type: string
|
||||||
|
secrets:
|
||||||
|
GH_PAT:
|
||||||
|
required: false
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
build_run_id:
|
build_run_id:
|
||||||
|
|||||||
@@ -1,6 +1,33 @@
|
|||||||
name: Publish Windows update feed
|
name: Publish Windows update feed
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
gpgui_ref:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
release_tag:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
version:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
channel:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
build:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
highlights:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
secrets:
|
||||||
|
GH_PAT:
|
||||||
|
required: true
|
||||||
|
CLOUDFLARE_ACCOUNT_ID:
|
||||||
|
required: false
|
||||||
|
CLOUDFLARE_API_TOKEN:
|
||||||
|
required: false
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
gpgui_ref:
|
gpgui_ref:
|
||||||
|
|||||||
@@ -1,33 +1,45 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
"""Retain one source pair per build run so retries cannot move branch refs."""
|
"""Retain one source and version identity per build run, including retries."""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import runpy
|
||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
def record(path, gp, gpgui, output):
|
def record(path, gp, gpgui, output, build_version):
|
||||||
if path.exists():
|
if path.exists():
|
||||||
sources = json.loads(path.read_text())
|
identity = json.loads(path.read_text())
|
||||||
else:
|
else:
|
||||||
sources = {
|
identity = {
|
||||||
name: subprocess.check_output(["git", "-C", str(root), "rev-parse", "HEAD"],
|
name: subprocess.check_output(["git", "-C", str(root), "rev-parse", "HEAD"],
|
||||||
text=True, stderr=subprocess.DEVNULL).strip()
|
text=True, stderr=subprocess.DEVNULL).strip()
|
||||||
for name, root in (("gp_sha", gp), ("gpgui_sha", gpgui))
|
for name, root in (("gp_sha", gp), ("gpgui_sha", gpgui))
|
||||||
}
|
}
|
||||||
if set(sources) != {"gp_sha", "gpgui_sha"} or any(
|
cargo_version = runpy.run_path(str(Path(__file__).with_name("validate-release-version.py")))["cargo_version"]
|
||||||
|
version = cargo_version(gp)
|
||||||
|
if cargo_version(gpgui) != version:
|
||||||
|
raise ValueError("public and desktop product versions differ")
|
||||||
|
identity.update(version=version, build_version=build_version)
|
||||||
|
if set(identity) != {"gp_sha", "gpgui_sha", "version", "build_version"} or any(
|
||||||
not isinstance(value, str) or not re.fullmatch(r"[0-9a-f]{40}", value)
|
not isinstance(value, str) or not re.fullmatch(r"[0-9a-f]{40}", value)
|
||||||
for value in sources.values()
|
for name, value in identity.items() if name.endswith("_sha")
|
||||||
):
|
):
|
||||||
raise ValueError("invalid retained build source refs")
|
raise ValueError("invalid retained build source refs")
|
||||||
|
if not isinstance(identity["version"], str) or not re.fullmatch(r"\d+\.\d+\.\d+", identity["version"]):
|
||||||
|
raise ValueError("invalid retained product version")
|
||||||
|
if not isinstance(identity["build_version"], str) or not re.fullmatch(
|
||||||
|
r"(0|[1-9]\d*)\.(0|[1-9]\d*)", identity["build_version"]
|
||||||
|
):
|
||||||
|
raise ValueError("invalid retained build version")
|
||||||
path.parent.mkdir(parents=True, exist_ok=True)
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
path.write_text(json.dumps(sources, indent=2) + "\n")
|
path.write_text(json.dumps(identity, indent=2) + "\n")
|
||||||
with output.open("a") as stream:
|
with output.open("a") as stream:
|
||||||
for name, sha in sources.items():
|
for name, value in identity.items():
|
||||||
stream.write(f"{name}={sha}\n")
|
stream.write(f"{name}={value}\n")
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -35,9 +47,10 @@ def main():
|
|||||||
parser.add_argument("path", type=Path)
|
parser.add_argument("path", type=Path)
|
||||||
parser.add_argument("--gp", type=Path, required=True)
|
parser.add_argument("--gp", type=Path, required=True)
|
||||||
parser.add_argument("--gpgui", type=Path, required=True)
|
parser.add_argument("--gpgui", type=Path, required=True)
|
||||||
|
parser.add_argument("--build-version", required=True)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
try:
|
try:
|
||||||
record(args.path, args.gp, args.gpgui, Path(os.environ["GITHUB_OUTPUT"]))
|
record(args.path, args.gp, args.gpgui, Path(os.environ["GITHUB_OUTPUT"]), args.build_version)
|
||||||
except (OSError, ValueError, subprocess.CalledProcessError):
|
except (OSError, ValueError, subprocess.CalledProcessError):
|
||||||
parser.exit(1, "Could not retain the selected build source refs.\n")
|
parser.exit(1, "Could not retain the selected build source refs.\n")
|
||||||
|
|
||||||
|
|||||||
@@ -90,24 +90,43 @@ class ReleaseVersionTests(unittest.TestCase):
|
|||||||
versions.validate(root, package=package)
|
versions.validate(root, package=package)
|
||||||
|
|
||||||
|
|
||||||
class SourceSelectionTests(unittest.TestCase):
|
class BuildIdentityTests(unittest.TestCase):
|
||||||
def test_retry_uses_original_sources_after_both_branches_advance(self):
|
def test_retry_uses_original_sources_after_both_branches_advance(self):
|
||||||
with tempfile.TemporaryDirectory() as temp:
|
with tempfile.TemporaryDirectory() as temp:
|
||||||
root = Path(temp)
|
root = Path(temp)
|
||||||
paths = [root / 'gp', root / 'gpgui']
|
paths = [root / 'gp', root / 'gpgui']
|
||||||
for repo in paths:
|
for repo in paths:
|
||||||
initialize(repo)
|
initialize(repo)
|
||||||
|
write_version(repo)
|
||||||
(repo / 'source').write_text('first')
|
(repo / 'source').write_text('first')
|
||||||
commit(repo, 'first')
|
commit(repo, 'first')
|
||||||
path, output = root / 'sources.json', root / 'output'
|
path, output = root / 'sources.json', root / 'output'
|
||||||
sources.record(path, *paths, output)
|
sources.record(path, *paths, output, '42.1')
|
||||||
original = json.loads(path.read_text())
|
original = json.loads(path.read_text())
|
||||||
for repo in paths:
|
for repo in paths:
|
||||||
|
write_version(repo, '3.2.0')
|
||||||
(repo / 'source').write_text('second')
|
(repo / 'source').write_text('second')
|
||||||
commit(repo, 'second')
|
commit(repo, 'second')
|
||||||
sources.record(path, *paths, output)
|
sources.record(path, *paths, output, '42.2')
|
||||||
self.assertEqual(json.loads(path.read_text()), original)
|
self.assertEqual(json.loads(path.read_text()), original)
|
||||||
self.assertEqual(output.read_text().count(f"gp_sha={original['gp_sha']}"), 2)
|
self.assertEqual(output.read_text().count(f"gp_sha={original['gp_sha']}"), 2)
|
||||||
|
self.assertEqual(original['version'], '3.1.0')
|
||||||
|
self.assertEqual(original['build_version'], '42.1')
|
||||||
|
sources.record(path, root / 'missing-gp', root / 'missing-gui', output, '42.3')
|
||||||
|
self.assertEqual(json.loads(path.read_text()), original)
|
||||||
|
|
||||||
|
def test_mismatched_product_versions_are_not_retained(self):
|
||||||
|
with tempfile.TemporaryDirectory() as temp:
|
||||||
|
root = Path(temp)
|
||||||
|
paths = [root / 'gp', root / 'gpgui']
|
||||||
|
for repo, version in zip(paths, ['3.1.0', '3.2.0']):
|
||||||
|
initialize(repo)
|
||||||
|
write_version(repo, version)
|
||||||
|
commit(repo, 'source')
|
||||||
|
path = root / 'sources.json'
|
||||||
|
with self.assertRaisesRegex(ValueError, 'versions differ'):
|
||||||
|
sources.record(path, *paths, root / 'output', '42.1')
|
||||||
|
self.assertFalse(path.exists())
|
||||||
|
|
||||||
def test_corrupt_retained_sources_do_not_resolve_again(self):
|
def test_corrupt_retained_sources_do_not_resolve_again(self):
|
||||||
with tempfile.TemporaryDirectory() as temp:
|
with tempfile.TemporaryDirectory() as temp:
|
||||||
@@ -115,7 +134,7 @@ class SourceSelectionTests(unittest.TestCase):
|
|||||||
path = root / 'sources.json'
|
path = root / 'sources.json'
|
||||||
path.write_text('{"gp_sha":"main","gpgui_sha":"main"}')
|
path.write_text('{"gp_sha":"main","gpgui_sha":"main"}')
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
sources.record(path, root, root, root / 'output')
|
sources.record(path, root, root, root / 'output', '42.1')
|
||||||
|
|
||||||
|
|
||||||
class PromotionTests(unittest.TestCase):
|
class PromotionTests(unittest.TestCase):
|
||||||
@@ -196,6 +215,65 @@ class SnapshotBranchTests(unittest.TestCase):
|
|||||||
self.assertEqual(git(origin, 'branch', '--list', 'main'), '')
|
self.assertEqual(git(origin, 'branch', '--list', 'main'), '')
|
||||||
|
|
||||||
|
|
||||||
|
class PublicationWorkflowTests(unittest.TestCase):
|
||||||
|
def job(self, name):
|
||||||
|
source = (ROOT / '.github/workflows/build.yaml').read_text()
|
||||||
|
return re.search(r'(?ms)^ ' + name + r':\n.*?(?=^ [\w-]+:|\Z)', source).group(0)
|
||||||
|
|
||||||
|
def decisions(self, name, cases):
|
||||||
|
expression = re.search(r'\$\{\{ (.*?) \}\}', self.job(name), re.DOTALL).group(1)
|
||||||
|
expression = re.sub(r'needs\.([\w-]+)\.result', r'needs["\1"].result', expression)
|
||||||
|
script = """
|
||||||
|
const cases = JSON.parse(process.argv[1]);
|
||||||
|
const allows = new Function('needs', 'inputs', 'github', 'cancelled',
|
||||||
|
'return (' + process.argv[2] + ')');
|
||||||
|
console.log(JSON.stringify(cases.map(c => allows(c.needs, c.inputs, c.github, () => c.cancelled))));
|
||||||
|
"""
|
||||||
|
return json.loads(subprocess.check_output(
|
||||||
|
['node', '-e', script, json.dumps(cases), expression], text=True))
|
||||||
|
|
||||||
|
def test_macos_assets_require_both_jobs_and_a_live_run(self):
|
||||||
|
job = self.job('publish-macos-assets')
|
||||||
|
self.assertIn('needs: [build-macos, gh-release]', job)
|
||||||
|
self.assertIn('uses: ./.github/workflows/publish-macos-assets.yaml', job)
|
||||||
|
cases, expected = [], []
|
||||||
|
for macos in ['success', 'failure', 'skipped', 'cancelled']:
|
||||||
|
for release in ['success', 'failure', 'skipped', 'cancelled']:
|
||||||
|
for cancelled in [False, True]:
|
||||||
|
cases.append({'needs': {'build-macos': {'result': macos},
|
||||||
|
'gh-release': {'result': release}},
|
||||||
|
'inputs': {}, 'github': {}, 'cancelled': cancelled})
|
||||||
|
expected.append(not cancelled and macos == release == 'success')
|
||||||
|
self.assertEqual(self.decisions('publish-macos-assets', cases), expected)
|
||||||
|
|
||||||
|
def test_snapshot_feeds_follow_selection_and_publication_results(self):
|
||||||
|
cases, expected_windows, expected_macos = [], [], []
|
||||||
|
for macos in [False, True]:
|
||||||
|
for windows in [False, True]:
|
||||||
|
for override in [{}, {'channel': 'stable'}, {'build_only': True},
|
||||||
|
{'event': 'push'}, {'cancelled': True}, {'release': 'failure'},
|
||||||
|
{'macos_publish': 'failure'}, {'windows_feed': 'failure'}]:
|
||||||
|
inputs = dict(channel='snapshot', build_only=False,
|
||||||
|
build_macos=macos, build_windows=windows)
|
||||||
|
inputs.update({key: value for key, value in override.items() if key in inputs})
|
||||||
|
release = override.get('release', 'success')
|
||||||
|
macos_publish = override.get('macos_publish', 'success') if macos else 'skipped'
|
||||||
|
windows_feed = override.get('windows_feed', 'success') if windows else 'skipped'
|
||||||
|
cancelled = override.get('cancelled', False)
|
||||||
|
event = override.get('event', 'workflow_dispatch')
|
||||||
|
cases.append({'needs': {'gh-release': {'result': release},
|
||||||
|
'publish-macos-assets': {'result': macos_publish},
|
||||||
|
'publish-windows-snapshot-feed': {'result': windows_feed}},
|
||||||
|
'inputs': inputs, 'github': {'event_name': event}, 'cancelled': cancelled})
|
||||||
|
ready = (not cancelled and event == 'workflow_dispatch' and
|
||||||
|
inputs['channel'] == 'snapshot' and not inputs['build_only'] and
|
||||||
|
release == 'success' and (not macos or macos_publish == 'success'))
|
||||||
|
expected_windows.append(ready and windows)
|
||||||
|
expected_macos.append(ready and macos and (not windows or windows_feed == 'success'))
|
||||||
|
self.assertEqual(self.decisions('publish-windows-snapshot-feed', cases), expected_windows)
|
||||||
|
self.assertEqual(self.decisions('publish-macos-unix-snapshot-feeds', cases), expected_macos)
|
||||||
|
|
||||||
|
|
||||||
class DockerMatrixTests(unittest.TestCase):
|
class DockerMatrixTests(unittest.TestCase):
|
||||||
def test_workflow_matrix_follows_all_architecture_choices(self):
|
def test_workflow_matrix_follows_all_architecture_choices(self):
|
||||||
source = (ROOT / '.github/workflows/release.yaml').read_text()
|
source = (ROOT / '.github/workflows/release.yaml').read_text()
|
||||||
|
|||||||
Reference in new issue
Block a user