-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (114 loc) · 3.47 KB
/
build-release.yml
File metadata and controls
136 lines (114 loc) · 3.47 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
name: build-release
on:
push:
branches:
- master
- main
tags:
- "v*"
pull_request:
workflow_dispatch:
permissions:
contents: read
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.10.1
args: ./...
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Unit Tests
run: go test ./...
- name: Readiness Check
run: go run ./scripts/readiness-check
package-release:
needs:
- lint
- test
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Package Release Artifacts
env:
CODEX_MEM_VERSION: ${{ github.ref_type == 'tag' && github.ref_name || github.sha }}
CODEX_MEM_COMMIT: ${{ github.sha }}
CODEX_MEM_BUILD_DATE: ${{ github.event.head_commit.timestamp || '' }}
run: go run ./scripts/package-release
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: codex-mem-release-artifacts
path: |
dist/*.zip
dist/*.tar.gz
dist/SHA256SUMS
- name: Generate Release Notes
if: startsWith(github.ref, 'refs/tags/v')
id: release_notes
run: |
CURRENT_TAG="${{ github.ref_name }}"
PREV_TAG=$(git tag --sort=-version:refname | grep -E '^v[0-9]' | sed -n '2p')
if [ -z "$PREV_TAG" ]; then
RANGE="HEAD"
else
RANGE="${PREV_TAG}..HEAD"
fi
# Collect commits (skip merge commits); escape backticks to prevent markdown code-fence breakage
COMMITS=$(git log $RANGE --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))" --no-merges \
| sed 's/`/\\`/g')
# Extract unique issue references (#123) from commit messages
ISSUES=$(git log $RANGE --pretty=format:"%s %b" --no-merges \
| grep -oE '#[0-9]+' | sort -u \
| sed 's|#\([0-9]*\)|[#\1](https://github.com/${{ github.repository }}/issues/\1)|' \
| tr '\n' ' ')
{
echo "## What's Changed"
echo ""
echo "$COMMITS"
if [ -n "$ISSUES" ]; then
echo ""
echo "## Referenced Issues"
echo ""
echo "$ISSUES"
fi
if [ -n "$PREV_TAG" ]; then
echo ""
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREV_TAG}...${CURRENT_TAG}"
fi
} > /tmp/release-notes.md
- name: Publish GitHub Release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
files: |
dist/*.zip
dist/*.tar.gz
dist/SHA256SUMS
fail_on_unmatched_files: true
body_path: /tmp/release-notes.md