1
1
# Create an incremental tag (like `cli-v1.2.0`) on Github using SemVer https://semver.org: x.y.z
2
- # Create the Release (like `cli-v1.2.0`) based on this tag and with the same name.
3
- # Build the CLI for all OS and upload them as assets to the release.
2
+ # Create the Release (like `cli-v1.2.0`) related to the tag and with the same name.
3
+ # Build the CLI for all OS and upload them to the release as assets .
4
4
5
5
name : Release CLI
6
6
16
16
- major
17
17
18
18
jobs :
19
- release-cli :
20
- if : ${{ github.ref == 'refs/heads/main' }}
21
- name : Release CLI
19
+ set-releasename :
20
+ runs-on : ubuntu-latest
21
+ name : New release name
22
+ outputs :
23
+ RELEASENAME : ${{ steps.set-outputs.outputs.RELEASENAME }}
24
+ steps :
25
+ - name : Checkout code
26
+ uses : actions/checkout@v4
27
+ with :
28
+ # download tags
29
+ fetch-depth : 0
30
+
31
+ - name : Last version
32
+ id : last-version
33
+ run : echo "LASTVERSION=$(git tag --list 'cli-v*' | sort -V | tail -n1 | sed 's/cli-v//')" >> $GITHUB_ENV
34
+
35
+ - name : Bump version
36
+ id : bump-version
37
+ uses : olegsu/semver-action@v1
38
+ with :
39
+ version : ${{ env.LASTVERSION }}
40
+ bump : ${{ inputs.choice }}
41
+
42
+ - name : Output release name
43
+ id : set-outputs
44
+ run : echo "RELEASENAME=cli-v${{ steps.bump-version.outputs.version }}" >> "$GITHUB_OUTPUT"
45
+
46
+ build-cli :
47
+ # if: ${{ github.ref == 'refs/heads/main' }}
48
+ needs : set-releasename
49
+ name : Build CLI
22
50
strategy :
23
51
matrix :
24
52
include :
@@ -36,69 +64,112 @@ jobs:
36
64
37
65
runs-on : ubuntu-latest
38
66
env :
67
+ RELEASENAME : ${{ needs.set-releasename.outputs.RELEASENAME }}
39
68
OSNAME : ${{matrix.goos == 'darwin' && 'macos' || matrix.goos }}
40
69
GOARCH : ${{ matrix.goarch }}
41
70
GOOS : ${{ matrix.goos }}
42
71
ARCHNAME : ${{ matrix.goarch == 'amd64' && 'x86-64' || matrix.goarch }}
72
+ outputs :
73
+ RELEASENAME : ${{ steps.set-outputs.outputs.RELEASENAME }}
43
74
steps :
44
75
- name : Checkout code
45
- uses : actions/checkout@v3
76
+ uses : actions/checkout@v4
46
77
47
- - name : Set env var
48
- run : echo "ZIPFILE=sqlitecloud-go-${{ steps.tag-and-release.outputs.name }}-${{ env.OSNAME }}-${{ env.ARCHNAME }}.zip" >> $GITHUB_ENV
78
+ - name : Set zipfile name
79
+ run : echo "ZIPFILE=sqlitecloud-go-${{ env.RELEASENAME }}-${{ env.OSNAME }}-${{ env.ARCHNAME }}.zip" >> $GITHUB_ENV
49
80
50
81
- name : Build CLI
51
82
run : |
52
- cd GO/ cli
83
+ cd cli
53
84
go build -o ../sqlc
54
85
cd ..
55
86
zip ${{ env.ZIPFILE }} sqlc
56
87
57
- - name : Last version
58
- id : last-version
59
- # last tag that starts with 'cli-v', eg: cli-v1.2.0 but outputs it as: v1.2.0
60
- run : echo "::set-output name=number::$(git tag --list 'cli-v*' | sort -V | tail -n1 | sed 's/cli-//')"
61
-
62
- - name : Bump version
63
- id : bump-version
64
- uses : olegsu/semver-action@v1
88
+ # Upload assets to be used in the last job
89
+ - name : Upload binary artifact
90
+ uses : actions/upload-artifact@v4
65
91
with :
66
- version : ${{ steps.last-version.outputs.number }}
67
- bump : ${{ inputs.choice }}
92
+ name : ${{ env.ZIPFILE }}
93
+ path : ./${{ env.ZIPFILE }}
94
+ if-no-files-found : error
95
+
96
+ - name : Set outputs
97
+ id : set-outputs
98
+ run : |
99
+ echo "RELEASENAME=${{ env.RELEASENAME }}" >> "$GITHUB_OUTPUT"
68
100
69
- - name : Tag and Release name
70
- id : tag-and-release
71
- # eg: cli-v1.2.0
72
- run : echo "::set-output name=name::cli-v$(git tag --list 'v*' | sort -V | tail -n1)"
101
+ release-cli :
102
+ name : Release CLI
103
+ needs : build-cli
104
+ runs-on : ubuntu-latest
105
+ env :
106
+ RELEASENAME : ${{ needs.build-cli.outputs.RELEASENAME }}
107
+ outputs :
108
+ RELEASENAME : ${{ steps.set-outputs.outputs.RELEASENAME }}
109
+ UPLOADURL : ${{ steps.set-outputs.outputs.UPLOADURL }}
110
+ steps :
111
+ - name : Checkout code
112
+ uses : actions/checkout@v4
73
113
74
114
- name : Create Release for CLI
75
115
id : release
76
116
uses : softprops/action-gh-release@v2
77
117
with :
78
- tag_name : ${{ steps.tag-and-release.outputs.name }}
79
- name : Release ${{ steps.tag-and-release.outputs.name }}
118
+ tag_name : ${{ env.RELEASENAME }}
119
+ name : Release ${{ env.RELEASENAME }}
80
120
draft : false
81
121
generate_release_notes : true
82
122
make_latest : true
83
123
env :
84
124
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
85
125
126
+ - name : Set outputs
127
+ id : set-outputs
128
+ run : |
129
+ echo "RELEASENAME=${{ env.RELEASENAME }}" >> "$GITHUB_OUTPUT"
130
+ echo "UPLOADURL=${{ steps.release.outputs.upload_url }}" >> "$GITHUB_OUTPUT"
131
+
132
+ upload-artifacts :
133
+ needs : release-cli
134
+ runs-on : ubuntu-latest
135
+ strategy :
136
+ matrix :
137
+ include :
138
+ - goarch : amd64
139
+ goos : linux
140
+
141
+ - goarch : amd64
142
+ goos : windows
143
+
144
+ - goarch : arm64
145
+ goos : darwin
146
+
147
+ - goarch : amd64
148
+ goos : darwin
149
+ env :
150
+ RELEASENAME : ${{ needs.release-cli.outputs.RELEASENAME }}
151
+ UPLOADURL : ${{ needs.release-cli.outputs.UPLOADURL }}
152
+ OSNAME : ${{matrix.goos == 'darwin' && 'macos' || matrix.goos }}
153
+ GOARCH : ${{ matrix.goarch }}
154
+ GOOS : ${{ matrix.goos }}
155
+ ARCHNAME : ${{ matrix.goarch == 'amd64' && 'x86-64' || matrix.goarch }}
156
+ steps :
157
+ - name : Set zip filename
158
+ run : echo "ZIPFILE=sqlitecloud-go-${{ env.RELEASENAME }}-${{ env.OSNAME }}-${{ env.ARCHNAME }}.zip" >> $GITHUB_ENV
159
+
160
+ - name : Download artifact
161
+ uses : actions/download-artifact@v4
162
+ with :
163
+ name : ${{ env.ZIPFILE }}
164
+
86
165
- name : Upload Release Asset
87
166
id : upload-release-asset
88
167
uses : actions/upload-release-asset@v1
89
168
if : matrix.goos != 'darwin'
90
169
env :
91
170
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
92
171
with :
93
- upload_url : ${{ steps.release.outputs.upload_url }}
94
- asset_path : ./GO/ ${{ env.ZIPFILE }}
172
+ upload_url : ${{ env.UPLOADURL }}
173
+ asset_path : ./${{ env.ZIPFILE }}
95
174
asset_name : ${{ env.ZIPFILE }}
96
175
asset_content_type : application/zip
97
-
98
- - name : Upload binary artifact
99
- uses : actions/upload-artifact@v3
100
- if : matrix.goos == 'darwin'
101
- with :
102
- name : ${{ env.ZIPFILE }}
103
- path : ./GO/${{ env.ZIPFILE }}
104
- if-no-files-found : error
0 commit comments