1+ name : Release
2+
3+ on :
4+ push :
5+ branches : [ "main","feature/release-pipeline"]
6+ pull_request :
7+ branches : [ main ]
8+ workflow_dispatch :
9+ inputs :
10+ version_bump :
11+ description : ' version bump type'
12+ required : false
13+ default : patch
14+ type : choice
15+ options :
16+ - patch
17+ - minor
18+ - major
19+
20+
21+ jobs :
22+ tests :
23+ name : Run Unit Tests
24+ runs-on : [ubuntu-latest]
25+ steps :
26+ - uses : actions/checkout@v5
27+ - name : Set up Go
28+ uses : actions/setup-go@v6
29+ with :
30+ go-version-file : go.mod
31+ - name : Lint code
32+ uses : golangci/golangci-lint-action@v8
33+ - name : Run Unit Tests
34+ run : |
35+ export CGO_ENABLED=0
36+ go version
37+ go run github.com/onsi/ginkgo/v2/ginkgo --skip-package=integration ./...
38+
39+ build-and-release :
40+ name : Build and Release
41+ needs : tests
42+ runs-on : ubuntu-latest
43+ steps :
44+ - name : Checkout Into Source Code
45+ uses : actions/checkout@v5
46+
47+ - name : Set up Go
48+ uses : actions/setup-go@v6
49+ with :
50+ go-version-file : go.mod
51+
52+ - name : Bump Version and Create Tag
53+ id : tag_version
54+ uses : anothrNick/github-tag-action@1.70.0
55+ env :
56+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
57+ DEFAULT_BUMP : ${{ github.event.inputs.version_bump || 'patch'}}
58+ WITH_V : true
59+
60+ - name : Export Version Variable
61+ run : |
62+ VERSION=${{steps.tag_version.outputs.new_tag}}
63+ VERSION_NUMBER=${VERSION#v}
64+ echo "VERSION_NUMBER=${VERSION_NUMBER}" >> $GITHUB_ENV
65+
66+ - name : Generate Changelog
67+ id : changelog
68+ uses : mikepenz/release-changelog-builder-action@v5
69+ with :
70+ toTag : ${{ steps.tag_version.outputs.new_tag }}
71+ commitMode : true
72+ env :
73+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
74+
75+ - name : Build for Linux
76+ env :
77+ GOOS : linux
78+ GOARCH : amd64
79+ CGO_ENABLED : 0
80+ VERSION : ${{ steps.tag_version.outputs.new_tag}}
81+ run : |
82+ echo "Building Storage CLI for Linux"
83+ go build -ldflags "-X main.version=${{ env.VERSION_NUMBER }}" \
84+ -o "storage-cli-${{ env.VERSION_NUMBER }}-linux-amd64"
85+ echo "### Linux Build Checksums" >> $GITHUB_STEP_SUMMARY
86+ echo '```' >> $GITHUB_STEP_SUMMARY
87+ sha1sum "storage-cli-${{ env.VERSION_NUMBER }}-linux-amd64" >> $GITHUB_STEP_SUMMARY
88+ echo '```' >> $GITHUB_STEP_SUMMARY
89+
90+ - name : Build for Windows
91+ env :
92+ GOOS : windows
93+ GOARCH : amd64
94+ CGO_ENABLED : 0
95+ VERSION : ${{ steps.tag_version.outputs.new_tag }}
96+ run : |
97+ echo "Building Storage CLI for Windows"
98+ go build -ldflags "-X main.version=${{ env.VERSION_NUMBER }}" \
99+ -o "storage-cli-${{ env.VERSION_NUMBER }}-windows-amd64.exe"
100+ echo "### Windows Build Checksums" >> $GITHUB_STEP_SUMMARY
101+ echo '```' >> $GITHUB_STEP_SUMMARY
102+ sha1sum "storage-cli-${{ env.VERSION_NUMBER }}-windows-amd64.exe" >> $GITHUB_STEP_SUMMARY
103+ echo '```' >> $GITHUB_STEP_SUMMARY
104+
105+ - name : Create Release
106+ uses : ncipollo/release-action@v1
107+ with :
108+ tag : ${{ steps.tag_version.outputs.new_tag }}
109+ name : Release ${{ steps.tag_version.outputs.new_tag }}
110+ body : ${{ steps.changelog.outputs.changelog }}
111+ artifacts : |
112+ storage-cli-${{ env.VERSION_NUMBER }}-linux-amd64
113+ storage-cli-${{ env.VERSION_NUMBER }}-windows-amd64.exe
114+ token : ${{ secrets.GITHUB_TOKEN }}
115+
116+ - name : Configure AWS credentials
117+ uses : aws-actions/configure-aws-credentials@v4
118+ with :
119+ aws-access-key-id : ${{ secrets.AWS_ACCESS_KEY_ID }}
120+ aws-secret-access-key : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
121+ aws-region : us-east-1
122+
123+ - name : Upload Artifacts to S3
124+ run : |
125+ aws s3 cp "storage-cli-${{ env.VERSION_NUMBER }}-linux-amd64" \
126+ "s3://storage-cli-artifacts/storage-cli-${{ env.VERSION_NUMBER }}-linux-amd64"
127+ aws s3 cp "storage-cli-${{ env.VERSION_NUMBER }}-windows-amd64.exe" \
128+ "s3://storage-cli-artifacts/storage-cli-${{ env.VERSION_NUMBER }}-windows-amd64.exe"
129+
130+
131+
132+
0 commit comments