-
Notifications
You must be signed in to change notification settings - Fork 6
203 lines (177 loc) · 7.76 KB
/
Copy pathrelease-cron.yml
File metadata and controls
203 lines (177 loc) · 7.76 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
name: Release Cron
on:
schedule:
- cron: '27 5 * * 3' # Every Wednesday at 05:27 UTC
workflow_dispatch:
permissions:
contents: write
statuses: write
jobs:
check:
name: Check for Changes
runs-on: ubuntu-latest
outputs:
should_release: ${{ steps.check.outputs.should_release }}
next_version: ${{ steps.check.outputs.next_version }}
steps:
- name: Checkout Into Source Code
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Check diff and compute next version
id: check
run: |
LATEST_TAG=$(git tag --sort=-version:refname | head -1)
if [ -z "$LATEST_TAG" ]; then
echo "No tags found, cannot determine next version"
exit 1
fi
echo "Latest tag: $LATEST_TAG"
if git diff "${LATEST_TAG}..HEAD" --quiet; then
echo "No changes since ${LATEST_TAG}, skipping release"
echo "should_release=false" >> $GITHUB_OUTPUT
echo "## No release needed" >> $GITHUB_STEP_SUMMARY
echo "No changes since ${LATEST_TAG}." >> $GITHUB_STEP_SUMMARY
exit 0
fi
VERSION_NUMBER=${LATEST_TAG#v}
MAJOR=$(echo $VERSION_NUMBER | cut -d. -f1)
MINOR=$(echo $VERSION_NUMBER | cut -d. -f2)
PATCH=$(echo $VERSION_NUMBER | cut -d. -f3)
NEXT_PATCH=$((PATCH + 1))
NEXT_VERSION="v${MAJOR}.${MINOR}.${NEXT_PATCH}"
echo "Next version: $NEXT_VERSION"
echo "should_release=true" >> $GITHUB_OUTPUT
echo "next_version=${NEXT_VERSION}" >> $GITHUB_OUTPUT
tests:
name: Run Unit Tests
needs: check
if: needs.check.outputs.should_release == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout Into Source Code
uses: actions/checkout@v7
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version-file: go.mod
- name: Lint code
uses: golangci/golangci-lint-action@v9
- name: Run Unit Tests
run: |
export CGO_ENABLED=0
go version
go run github.com/onsi/ginkgo/v2/ginkgo --skip-package=integration ./...
integration-s3:
name: Integration Tests - S3
needs: [check, tests]
if: needs.tests.result == 'success'
uses: ./.github/workflows/s3-integration.yml
secrets: inherit
integration-gcs:
name: Integration Tests - GCS
needs: [check, tests]
if: needs.tests.result == 'success'
uses: ./.github/workflows/gcs-integration.yml
secrets: inherit
integration-azurebs:
name: Integration Tests - Azure Blob Storage
needs: [check, tests]
if: needs.tests.result == 'success'
uses: ./.github/workflows/azurebs-integration.yml
secrets: inherit
integration-alioss:
name: Integration Tests - Alibaba OSS
needs: [check, tests]
if: needs.tests.result == 'success'
uses: ./.github/workflows/alioss-integration.yml
secrets: inherit
integration-dav:
name: Integration Tests - DAV
needs: [check, tests]
if: needs.tests.result == 'success'
uses: ./.github/workflows/dav-integration.yml
secrets: inherit
build-and-release:
name: Build and Release
needs: [check, tests, integration-s3, integration-gcs, integration-azurebs, integration-alioss, integration-dav]
if: needs.tests.result == 'success'
runs-on: ubuntu-latest
steps:
- name: Checkout Into Source Code
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version-file: go.mod
- name: Set version variables
id: version
run: |
VERSION="${{ needs.check.outputs.next_version }}"
VERSION_NUMBER=${VERSION#v}
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "VERSION_NUMBER=$VERSION_NUMBER" >> $GITHUB_OUTPUT
echo "Building version: $VERSION (number: $VERSION_NUMBER)"
- name: Create Tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "${{ steps.version.outputs.VERSION }}" -m "Release ${{ steps.version.outputs.VERSION }}"
git push origin "${{ steps.version.outputs.VERSION }}"
- name: Build for Linux
run: |
echo "Building Storage CLI for Linux"
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X main.version=${{ steps.version.outputs.VERSION_NUMBER }}" \
-o "storage-cli-${{ steps.version.outputs.VERSION_NUMBER }}-linux-amd64"
echo "### Linux amd64 Build Checksums" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
sha1sum "storage-cli-${{ steps.version.outputs.VERSION_NUMBER }}-linux-amd64" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags "-X main.version=${{ steps.version.outputs.VERSION_NUMBER }}" \
-o "storage-cli-${{ steps.version.outputs.VERSION_NUMBER }}-linux-arm64"
echo "### Linux arm64 Build Checksums" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
sha1sum "storage-cli-${{ steps.version.outputs.VERSION_NUMBER }}-linux-arm64" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- name: Build for macOS
run: |
echo "Building Storage CLI for macOS"
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X main.version=${{ steps.version.outputs.VERSION_NUMBER }}" \
-o "storage-cli-${{ steps.version.outputs.VERSION_NUMBER }}-darwin-amd64"
echo "### macOS amd64 Build Checksums" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
sha1sum "storage-cli-${{ steps.version.outputs.VERSION_NUMBER }}-darwin-amd64" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -ldflags "-X main.version=${{ steps.version.outputs.VERSION_NUMBER }}" \
-o "storage-cli-${{ steps.version.outputs.VERSION_NUMBER }}-darwin-arm64"
echo "### macOS arm64 Build Checksums" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
sha1sum "storage-cli-${{ steps.version.outputs.VERSION_NUMBER }}-darwin-arm64" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- name: Build for Windows
run: |
echo "Building Storage CLI for Windows"
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X main.version=${{ steps.version.outputs.VERSION_NUMBER }}" \
-o "storage-cli-${{ steps.version.outputs.VERSION_NUMBER }}-windows-amd64.exe"
echo "### Windows Build Checksums" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
sha1sum "storage-cli-${{ steps.version.outputs.VERSION_NUMBER }}-windows-amd64.exe" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- name: Create Github Release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.version.outputs.VERSION }}
name: Release ${{ steps.version.outputs.VERSION }}
body: Release ${{ steps.version.outputs.VERSION }}
artifacts: |
storage-cli-${{ steps.version.outputs.VERSION_NUMBER }}-linux-amd64
storage-cli-${{ steps.version.outputs.VERSION_NUMBER }}-linux-arm64
storage-cli-${{ steps.version.outputs.VERSION_NUMBER }}-darwin-amd64
storage-cli-${{ steps.version.outputs.VERSION_NUMBER }}-darwin-arm64
storage-cli-${{ steps.version.outputs.VERSION_NUMBER }}-windows-amd64.exe
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
makeLatest: true
generateReleaseNotes: true