Repository navigation
150 lines (150 loc) · 9.1 KB
/
Copy pathrelease-github.yml
File metadata and controls
150 lines (150 loc) · 9.1 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: Release verified v0.7.0 assets
on:
workflow_dispatch:
inputs:
source_sha:
description: Full release source commit
type: string
required: true
tag_object_sha:
description: Immutable annotated v0.7.0 tag object
type: string
required: true
registry_sha256:
description: Canonical published source ZIP SHA-256
type: string
required: true
native_run_id:
description: Successful three-platform source CI run
type: string
required: true
registry_run_id:
description: Successful source and registry-only SDK verification run
type: string
required: true
registry_attempt:
description: Registry verification run attempt
type: string
default: '1'
required: true
permissions:
contents: write
actions: read
concurrency:
group: release-github-v0.7.0
cancel-in-progress: false
jobs:
release:
if: github.repository == 'Delthin/moon-repomix'
runs-on: ubuntu-latest
timeout-minutes: 15
env:
SOURCE_SHA: ${{ inputs.source_sha }}
TAG_OBJECT_SHA: ${{ inputs.tag_object_sha }}
REGISTRY_SHA256: ${{ inputs.registry_sha256 }}
NATIVE_RUN_ID: ${{ inputs.native_run_id }}
REGISTRY_RUN_ID: ${{ inputs.registry_run_id }}
REGISTRY_ATTEMPT: ${{ inputs.registry_attempt }}
GH_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.sha }}
fetch-depth: 0
persist-credentials: false
- name: Initialize owned output and validate inputs
shell: bash
run: |
set -euo pipefail
[[ "$SOURCE_SHA" =~ ^[0-9a-f]{40}$ ]]
[[ "$TAG_OBJECT_SHA" =~ ^[0-9a-f]{40}$ ]]
[[ "$REGISTRY_SHA256" =~ ^[0-9a-f]{64}$ ]]
[[ "$NATIVE_RUN_ID" =~ ^[1-9][0-9]*$ ]]
[[ "$REGISTRY_RUN_ID" =~ ^[1-9][0-9]*$ ]]
[[ "$REGISTRY_ATTEMPT" =~ ^[1-9][0-9]*$ ]]
OUT="$RUNNER_TEMP/verified-release-070-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT"
mkdir "$OUT"
mkdir "$OUT/native" "$OUT/registry" "$OUT/assets" "$OUT/report"
printf 'OUT=%s\n' "$OUT" >> "$GITHUB_ENV"
- name: Require the immutable tag and successful source checks
shell: bash
run: |
set -euo pipefail
test "$GITHUB_SHA" = "$SOURCE_SHA"
test "$(git rev-parse 'v0.7.0^{}')" = "$SOURCE_SHA"
gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/v0.7.0" > "$OUT/report/tag-ref-before.json"
jq -e --arg tag "$TAG_OBJECT_SHA" '.object.type == "tag" and .object.sha == $tag' "$OUT/report/tag-ref-before.json"
gh api "repos/$GITHUB_REPOSITORY/git/tags/$TAG_OBJECT_SHA" > "$OUT/report/tag-object.json"
jq -e --arg sha "$SOURCE_SHA" '.tag == "v0.7.0" and .object.type == "commit" and .object.sha == $sha' "$OUT/report/tag-object.json"
gh run view "$NATIVE_RUN_ID" --repo "$GITHUB_REPOSITORY" --json headSha,status,conclusion,jobs > "$OUT/report/native-ci.json"
jq -e --arg sha "$SOURCE_SHA" '.headSha == $sha and .status == "completed" and .conclusion == "success" and (.jobs | length) == 3 and all(.jobs[]; .conclusion == "success")' "$OUT/report/native-ci.json"
gh run view "$REGISTRY_RUN_ID" --repo "$GITHUB_REPOSITORY" --json headSha,status,conclusion,jobs > "$OUT/report/registry-ci.json"
jq -e --arg sha "$SOURCE_SHA" '.headSha == $sha and .status == "completed" and .conclusion == "success" and (.jobs | length) > 0 and all(.jobs[]; .conclusion == "success")' "$OUT/report/registry-ci.json"
if gh release view v0.7.0 --repo "$GITHUB_REPOSITORY" --json id > "$OUT/report/preexisting-release.json" 2> "$OUT/report/preflight.stderr"; then
echo "Release already exists; inspect it before any further mutation" >&2
exit 1
fi
grep -q 'release not found' "$OUT/report/preflight.stderr"
- name: Download verified native and registry artifacts
shell: bash
run: |
set -euo pipefail
gh run download "$NATIVE_RUN_ID" --repo "$GITHUB_REPOSITORY" --name moon-repomix-macos-arm64 --name moon-repomix-linux-x64 --name moon-repomix-windows-x64 --dir "$OUT/native"
gh run download "$REGISTRY_RUN_ID" --repo "$GITHUB_REPOSITORY" --name "mooncakes-release-0.7.0-$REGISTRY_RUN_ID-$REGISTRY_ATTEMPT" --dir "$OUT/registry"
test "$(tr -d '\r\n' < "$OUT/registry/source-revision.txt")" = "$SOURCE_SHA"
jq -e --arg sha "$REGISTRY_SHA256" '.version == "0.7.0" and .yanked == false and .checksum == $sha' "$OUT/registry/registry-release.json"
jq -e --arg sha "$REGISTRY_SHA256" '.sourceEntriesEqual == true and (.entryCount | type == "number" and . > 0 and floor == .) and .registryZipSha256 == $sha and .expectedZipSha256 == $sha' "$OUT/registry/source-comparison.json"
jq -e '.version == "0.7.0" and .security == "Passed" and .dependencyMode == "registry-only script imports; no workspace or local replacements" and .progressiveContext.code.status == "complete" and .progressiveContext.task.status == "complete" and .portableRequest.path == "inventory.mbt" and .portableRequest.status == "complete"' "$OUT/registry/sdk/manifest.json"
cp "$OUT/native/moon-repomix-macos-arm64/moon-repomix-macos-arm64.tar.gz" "$OUT/assets/"
cp "$OUT/native/moon-repomix-linux-x64/moon-repomix-linux-x64.tar.gz" "$OUT/assets/"
cp "$OUT/native/moon-repomix-windows-x64/moon-repomix-windows-x64.tar.gz" "$OUT/assets/"
cp "$OUT/registry/Delthin-moon_repomix-0.7.0.zip" "$OUT/assets/"
printf '%s %s\n' "$REGISTRY_SHA256" "$OUT/assets/Delthin-moon_repomix-0.7.0.zip" | sha256sum -c -
cp "$OUT/registry/sdk/manifest.json" "$OUT/report/sdk-manifest.json"
cp "$OUT/registry/registry-release.json" "$OUT/report/registry-release.json"
cp "$OUT/registry/source-comparison.json" "$OUT/report/source-comparison.json"
- name: Prepare documented assets and checksums
shell: bash
run: |
set -euo pipefail
{
printf '# v0.7.0 性能资料\n\n发行源码:`%s`。构建要求 MoonBit `>=0.10.20`,实际工具链见本版关联的 CI 记录。下文沿用各表注明工具链和固定输入的既有性能测量。\n\n' "$SOURCE_SHA"
git show "$SOURCE_SHA:docs/performance.md"
} > "$OUT/assets/PERFORMANCE.md"
cp .github/release-notes-v0.7.0.md "$OUT/report/release-notes.md"
cd "$OUT/assets"
sha256sum *.tar.gz *.zip PERFORMANCE.md > SHA256SUMS
sha256sum -c SHA256SUMS
test "$(find . -maxdepth 1 -type f | wc -l)" -eq 6
cp SHA256SUMS "$OUT/report/SHA256SUMS"
- name: Create draft and validate uploaded asset digests
shell: bash
run: |
set -euo pipefail
# The existing annotated tag pins source; target_commitish is unused.
gh release create v0.7.0 "$OUT"/assets/* --repo "$GITHUB_REPOSITORY" --verify-tag --title v0.7.0 --notes-file "$OUT/report/release-notes.md" --draft
gh release view v0.7.0 --repo "$GITHUB_REPOSITORY" --json tagName,targetCommitish,isDraft,isPrerelease,assets,url > "$OUT/report/github-draft.json"
jq -e '.tagName == "v0.7.0" and .isDraft == true and .isPrerelease == false and (.assets | length) == 6 and all(.assets[]; .state == "uploaded")' "$OUT/report/github-draft.json"
gh api "repos/$GITHUB_REPOSITORY/releases?per_page=100" --jq '.[] | select(.tag_name == "v0.7.0")' > "$OUT/report/github-draft-api.json"
while read -r HASH NAME; do
jq -e --arg name "$NAME" --arg digest "sha256:$HASH" 'any(.assets[]; .name == $name and .digest == $digest)' "$OUT/report/github-draft-api.json"
done < "$OUT/assets/SHA256SUMS"
- name: Publish the verified release
shell: bash
run: |
set -euo pipefail
gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/v0.7.0" > "$OUT/report/tag-ref-draft.json"
jq -e --arg tag "$TAG_OBJECT_SHA" '.object.type == "tag" and .object.sha == $tag' "$OUT/report/tag-ref-draft.json"
gh release edit v0.7.0 --repo "$GITHUB_REPOSITORY" --draft=false --latest
gh release view v0.7.0 --repo "$GITHUB_REPOSITORY" --json tagName,targetCommitish,isDraft,isPrerelease,publishedAt,assets,url > "$OUT/report/github-release.json"
jq -e '.tagName == "v0.7.0" and .isDraft == false and .isPrerelease == false and (.assets | length) == 6' "$OUT/report/github-release.json"
gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/v0.7.0" > "$OUT/report/tag-ref-published.json"
jq -e --arg tag "$TAG_OBJECT_SHA" '.object.type == "tag" and .object.sha == $tag' "$OUT/report/tag-ref-published.json"
- name: Preserve public release evidence
if: always() && env.OUT != ''
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: github-release-0.7.0-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ env.OUT }}/report/
if-no-files-found: warn
retention-days: 14