-
Notifications
You must be signed in to change notification settings - Fork 0
166 lines (145 loc) · 5.32 KB
/
Copy pathrelease.yml
File metadata and controls
166 lines (145 loc) · 5.32 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: Existing v* tag to publish
required: true
type: string
permissions:
contents: write
concurrency:
group: release-${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
cancel-in-progress: false
jobs:
release:
name: Build release artifacts
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Resolve manual tag
if: github.event_name == 'workflow_dispatch'
env:
RELEASE_TAG: ${{ inputs.tag }}
run: git checkout --detach "$RELEASE_TAG"
- name: Validate tag
env:
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
run: |
tag="$RELEASE_TAG"
case "$tag" in
v*) ;;
*) echo "release tag must start with v: $tag" >&2; exit 1 ;;
esac
test "$(git rev-parse "$tag^{commit}")" = "$(git rev-parse HEAD)"
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Run tests
run: go test ./...
- name: Run release automation tests
run: python3 -m unittest scripts/release/test_generate_notes.py
- name: Check diff whitespace
run: git diff --check
- name: Build artifacts
run: ./scripts/release/build.sh
- name: Verify linux binary version
env:
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
run: |
tag="$RELEASE_TAG"
version="${tag#v}"
test "$(./dist/gitcode-mcp_${tag}_linux_amd64/gitcode-mcp --version)" = "gitcode-mcp $version"
- name: Generate release notes
env:
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
run: |
tag="$RELEASE_TAG"
notes_path="dist/release-notes.md"
asset_args=()
supplement_args=()
supplement_path=".github/release-notes/${tag}.md"
if [ -f "$supplement_path" ]; then
supplement_args+=(--supplement "$supplement_path")
fi
for asset in dist/*.tar.gz dist/*.zip dist/checksums.txt; do
name="$(basename "$asset")"
url="https://github.com/${GITHUB_REPOSITORY}/releases/download/${tag}/${name}"
asset_args+=(--asset "$name=$url")
done
python3 scripts/release/generate_notes.py \
--tag "$tag" \
--gitcode-web-base-url https://gitcode.com/urandon/gitcode-mcp \
--output "$notes_path" \
"${supplement_args[@]}" \
"${asset_args[@]}"
notes_sha="$(sha256sum "$notes_path" | awk '{print $1}')"
{
echo "### Release notes"
echo
echo "- Tag: \`$tag\`"
echo "- Input: \`$notes_path\`"
echo "- SHA-256: \`$notes_sha\`"
} >> "$GITHUB_STEP_SUMMARY"
- name: Publish GitHub release
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
run: |
tag="$RELEASE_TAG"
if gh release view "$tag" >/dev/null 2>&1; then
gh release edit "$tag" \
--title "gitcode-mcp $tag" \
--notes-file dist/release-notes.md
gh release upload "$tag" dist/*.tar.gz dist/*.zip dist/checksums.txt --clobber
else
gh release create "$tag" dist/*.tar.gz dist/*.zip dist/checksums.txt \
--title "gitcode-mcp $tag" \
--notes-file dist/release-notes.md \
--verify-tag
fi
- name: Publish GitCode release
env:
GITCODE_TOKEN: ${{ secrets.GITCODE_TOKEN }}
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
run: |
if [ -z "$GITCODE_TOKEN" ]; then
echo "GITCODE_TOKEN is not configured; skipping GitCode release publish."
exit 0
fi
tag="$RELEASE_TAG"
cache_path="$RUNNER_TEMP/gitcode-mcp-cache.db"
notes_path="dist/release-notes.md"
repo="urandon/gitcode-mcp"
go run ./cmd/gitcode-mcp repo add \
--cache-path "$cache_path" \
--repo "$repo" \
--owner urandon \
--name gitcode-mcp \
--api-base-url https://api.gitcode.com \
--scopes issues
asset_args=()
for asset in dist/*.tar.gz dist/*.zip dist/checksums.txt; do
name="$(basename "$asset")"
url="https://github.com/${GITHUB_REPOSITORY}/releases/download/${tag}/${name}"
asset_args+=(--asset "$name=$url")
done
go run ./cmd/gitcode-mcp publish-release \
--cache-path "$cache_path" \
--repo "$repo" \
--tag "$tag" \
--ref main \
--title "gitcode-mcp $tag" \
--input "$notes_path" \
--status latest \
--idempotency-key "release-$tag" \
"${asset_args[@]}" \
--format json