-
Notifications
You must be signed in to change notification settings - Fork 0
167 lines (137 loc) · 7.23 KB
/
ci.yaml
File metadata and controls
167 lines (137 loc) · 7.23 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
167
name: CI
on:
push:
branches: [master, main]
pull_request:
jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- goos: js
goarch: wasm
- goos: aix
goarch: ppc64
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: "1.23"
- name: Build
run: go build .
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
release:
name: Release
runs-on: ubuntu-latest
needs: build
outputs:
new_version: ${{ steps.semantic_release.outputs.new_version }}
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 20
- name: Install dependencies
run: npm install -g semantic-release conventional-changelog-conventionalcommits @semantic-release/exec @semantic-release/git @semantic-release/github @semantic-release/changelog @semantic-release/release-notes-generator
- name: Release
id: semantic_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: semantic-release
publish-go-docs:
name: Publish to Go Package Docs
runs-on: ubuntu-latest
needs: release
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: "1.23"
- name: Get new version from release
id: get_version
run: |
# Wait a bit for the tag to be available
sleep 10
# Get the latest git tag (should be the one just created)
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -n "$LATEST_TAG" ]; then
echo "new_version=$LATEST_TAG" >> $GITHUB_OUTPUT
echo "Found new version: $LATEST_TAG"
else
echo "No new version found, skipping publication"
echo "new_version=" >> $GITHUB_OUTPUT
fi
- name: Wait for tag to propagate
if: steps.get_version.outputs.new_version != ''
run: |
echo "Waiting for tag ${{ steps.get_version.outputs.new_version }} to propagate..."
sleep 30
# Verify the tag exists remotely
for i in {1..5}; do
if git ls-remote --tags origin | grep -q "${{ steps.get_version.outputs.new_version }}"; then
echo "Tag ${{ steps.get_version.outputs.new_version }} confirmed on remote"
break
else
echo "Attempt $i: Tag not yet available remotely, waiting..."
sleep 15
fi
done
- name: Publish to Go proxy
if: steps.get_version.outputs.new_version != ''
run: |
echo "Publishing version ${{ steps.get_version.outputs.new_version }} to Go proxy..."
# Run go mod tidy to ensure dependencies are clean
go mod tidy
# Run tests one final time (exclude examples to avoid main function conflicts)
go test -v $(go list ./... | grep -v examples)
# Step 1: Publish to Go proxy by requesting the module
echo "Adding module to Go proxy..."
GOPROXY=proxy.golang.org go list -m github.com/ZanzyTHEbar/assert-lib@${{ steps.get_version.outputs.new_version }}
# Step 2: Trigger pkg.go.dev indexing via proxy API
echo "Triggering pkg.go.dev indexing via proxy API..."
curl -f "https://proxy.golang.org/github.com/zanzythebar/assert-lib/@v/${{ steps.get_version.outputs.new_version }}.info" || echo "Proxy API call failed, continuing..."
# Step 3: Simulate real module usage to ensure indexing
echo "Simulating module download to trigger indexing..."
go clean -modcache
GOPROXY=proxy.golang.org go mod download github.com/ZanzyTHEbar/assert-lib@${{ steps.get_version.outputs.new_version }}
echo "Successfully published github.com/ZanzyTHEbar/assert-lib@${{ steps.get_version.outputs.new_version }} to Go proxy"
echo "Module should now be available at: https://pkg.go.dev/github.com/ZanzyTHEbar/assert-lib@${{ steps.get_version.outputs.new_version }}"
- name: Trigger pkg.go.dev indexing
if: steps.get_version.outputs.new_version != ''
run: |
echo "Triggering pkg.go.dev indexing for version ${{ steps.get_version.outputs.new_version }}..."
# Method 1: Direct request to pkg.go.dev to trigger indexing
echo "Requesting pkg.go.dev to index the new version..."
curl -f "https://pkg.go.dev/github.com/ZanzyTHEbar/assert-lib@${{ steps.get_version.outputs.new_version }}" > /dev/null 2>&1 || echo "Initial pkg.go.dev request completed (may still be indexing)"
# Method 2: Request the module info page which often triggers indexing
curl -f "https://pkg.go.dev/github.com/ZanzyTHEbar/assert-lib?tab=versions" > /dev/null 2>&1 || echo "Versions page request completed"
# Wait for indexing to process
echo "Waiting for pkg.go.dev indexing to complete..."
sleep 60
# Verify the new version is available (non-fatal)
echo "Verifying pkg.go.dev availability..."
if curl -f --max-time 30 "https://pkg.go.dev/github.com/ZanzyTHEbar/assert-lib@${{ steps.get_version.outputs.new_version }}" > /dev/null 2>&1; then
echo "✅ Package ${{ steps.get_version.outputs.new_version }} is now available on pkg.go.dev!"
else
echo "⏳ Package may still be indexing. It should appear on pkg.go.dev within a few minutes."
fi
echo "🔗 Package page: https://pkg.go.dev/github.com/ZanzyTHEbar/assert-lib"
echo "🔗 Version page: https://pkg.go.dev/github.com/ZanzyTHEbar/assert-lib@${{ steps.get_version.outputs.new_version }}"