Repository navigation
76 lines (66 loc) · 2.01 KB
/
Copy pathrelease.yml
File metadata and controls
76 lines (66 loc) · 2.01 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
name: Publish release
on:
push:
branches: [master]
paths:
- package.json
- CHANGELOG.md
permissions:
contents: write
concurrency:
group: publish-release
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Read package version
id: version
shell: bash
run: |
set -euo pipefail
version=$(node -p "require('./package.json').version")
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "tag=v$version" >> "$GITHUB_OUTPUT"
- name: Prepare release notes
shell: bash
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
set -euo pipefail
awk -v heading="## [$VERSION]" '
index($0, heading) == 1 { capture = 1; next }
capture && /^## \[/ { exit }
capture { print }
' CHANGELOG.md > release-notes.md
if [ ! -s release-notes.md ]; then
echo "OpenCode Agent Loop v$VERSION" > release-notes.md
fi
- name: Create tag and GitHub Release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.version.outputs.tag }}
VERSION: ${{ steps.version.outputs.version }}
run: |
set -euo pipefail
if gh release view "$TAG" >/dev/null 2>&1; then
echo "Release $TAG already exists; nothing to do."
exit 0
fi
if git rev-parse -q --verify "refs/tags/$TAG" >/dev/null; then
gh release create "$TAG" \
--title "OpenCode Agent Loop v$VERSION" \
--notes-file release-notes.md
else
gh release create "$TAG" \
--target "$GITHUB_SHA" \
--title "OpenCode Agent Loop v$VERSION" \
--notes-file release-notes.md
fi