@@ -2,10 +2,83 @@ name: CD
2
2
3
3
on :
4
4
release :
5
- types : [ published ]
5
+ types : [published]
6
6
7
7
jobs :
8
8
refresh :
9
9
runs-on : ubuntu-latest
10
10
steps :
11
- - uses : siyul-park/notify-pkg-go-dev@v1
11
+ - run : |
12
+ # Parameters from the Action inputs
13
+ BASE_URL="https://pkg.go.dev/fetch"
14
+ REPO_URL="github.com/${{ github.repository }}"
15
+ RELEASE_TAG="${{ github.event.release.tag_name }}"
16
+
17
+ # If the tag contains '/', replace the last '/' with '@'
18
+ if [[ "$RELEASE_TAG" == *"/"* ]]; then
19
+ FORMATTED_TAG="/${RELEASE_TAG%/*}@${RELEASE_TAG##*/}"
20
+ else
21
+ FORMATTED_TAG="@${RELEASE_TAG}"
22
+ fi
23
+
24
+ # Construct the full URL
25
+ FULL_URL="${BASE_URL}/${REPO_URL}${FORMATTED_TAG}"
26
+ echo "Sending POST request to $FULL_URL"
27
+
28
+ # Send the POST request
29
+ curl -X POST "$FULL_URL" --fail || echo "Failed to notify pkg.go.dev"
30
+
31
+ commit :
32
+ needs : refresh
33
+ strategy :
34
+ matrix :
35
+ os : [ubuntu-22.04]
36
+ go : ['1.22']
37
+ runs-on : ubuntu-latest
38
+ permissions :
39
+ contents : write
40
+ steps :
41
+ - uses : actions/checkout@v4
42
+ with :
43
+ ref : ${{ github.head_ref }}
44
+
45
+ - uses : actions/setup-go@v5
46
+ with :
47
+ go-version : ${{ matrix.go }}
48
+
49
+ - uses : actions/cache@v4
50
+ with :
51
+ path : |
52
+ ~/.cache/go-build
53
+ ~/go/pkg/mod
54
+ key : ${{ runner.os }}-${{ matrix.go }}-${{ hashFiles('**/go.sum') }}
55
+ restore-keys : ${{ runner.os }}-${{ matrix.go }}-${{ hashFiles('**/go.sum') }}
56
+
57
+ - name : Update Dependency
58
+ run : make update
59
+
60
+ - name : Update go.work
61
+ run : |
62
+ REPO_URL="github.com/${{ github.repository }}"
63
+ RELEASE_TAG="${{ github.event.release.tag_name }}"
64
+
65
+ # If the tag contains '/', replace the last '/' with '@'
66
+ if [[ "$RELEASE_TAG" == *"/"* ]]; then
67
+ PACKAGE_URL="${REPO_URL}/${RELEASE_TAG%/*}"
68
+ PACKAGE_VERSION="${RELEASE_TAG##*/}"
69
+ else
70
+ PACKAGE_URL="${REPO_URL}"
71
+ PACKAGE_VERSION="${RELEASE_TAG}"
72
+ fi
73
+
74
+ GO_WORK_FILE=".go.work"
75
+
76
+ # Update the go.work file using sed to replace the version
77
+ sed -i -E \
78
+ -e "s|${PACKAGE_URL} v[0-9]+\.[0-9]+\.[0-9]+|${PACKAGE_URL} ${PACKAGE_VERSION}|" \
79
+ "$GO_WORK_FILE"
80
+
81
+ - uses : stefanzweifel/git-auto-commit-action@v5
82
+ with :
83
+ commit_message : " chore(deploy): deploy ${{ github.event.release.tag_name }} version"
84
+ branch : main
0 commit comments