27
27
description : |
28
28
If building a sub-project only, you can specify a working directory
29
29
which is the path to that sub-project.
30
+ target-os :
31
+ required : false
32
+ type : string
33
+ default : " "
34
+ description : |
35
+ If you need to filter which platform uploads the artifact.
30
36
is-packaged :
31
37
required : false
32
38
type : boolean
43
49
description : |
44
50
The name to use for the github actifact that will be uploaded.
45
51
# The path that we should upload artifacts from
46
- artifact-output-paths :
52
+ artifact-output-path :
47
53
required : false
48
54
type : string
49
55
default : " "
55
61
type : string
56
62
default : " "
57
63
description : A sepcific ref to build for (i.e. a version or commit)
64
+ zig-args :
65
+ required : false
66
+ type : string
67
+ default : " "
68
+ description : Arguments to add to the zig build command
58
69
secrets :
59
70
# The downloads url for the packaging step. This is used in boxzer to
60
71
# fill in the manifest downloads location
63
74
description : |
64
75
The download url that will be included in the boxzer manifest output.
65
76
If the "is-packaged" option is false, this will not be used.
77
+ outputs :
78
+ issemver :
79
+ description : Whether or not it was built with a semver
80
+ value : ${{ jobs.build-zig.outputs.issemver }}
81
+ major :
82
+ description : The major version of the semver
83
+ value : ${{ jobs.build-zig.outputs.major }}
84
+ minor :
85
+ description : The minor version of the semver
86
+ value : ${{ jobs.build-zig.outputs.minor }}
87
+ patch :
88
+ description : The patch version of the semver
89
+ value : ${{ jobs.build-zig.outputs.patch }}
90
+ prerelease :
91
+ description : The prerelease info of the semver
92
+ value : ${{ jobs.build-zig.outputs.prerelease }}
93
+ build :
94
+ description : The build info of the semver
95
+ value : ${{ jobs.build-zig.outputs.build }}
96
+ version :
97
+ description : The full semver string
98
+ value : ${{ jobs.build-zig.outputs.version }}
66
99
67
100
jobs :
68
101
build-zig :
69
102
runs-on : ${{ matrix.os }}
70
103
strategy :
71
104
matrix :
72
105
os : [ubuntu-latest, windows-latest, macos-latest]
106
+ outputs :
107
+ issemver : ${{ steps.semver.outputs.issemver }}
108
+ major : ${{ steps.semver.outputs.major }}
109
+ minor : ${{ steps.semver.outputs.minor }}
110
+ patch : ${{ steps.semver.outputs.patch }}
111
+ prerelease : ${{ steps.semver.outputs.prerelease }}
112
+ build : ${{ steps.semver.outputs.build }}
113
+ version : ${{ steps.semver.outputs.version }}
73
114
steps :
74
115
# If we just want to use the current commit, simply run a checkout
75
116
- name : Checkout
@@ -86,10 +127,13 @@ jobs:
86
127
ref : ${{ inputs.ref }}
87
128
sparse-checkout : ${{ inputs.sparse-checkout-patterns }}
88
129
submodules : ${{ inputs.get-submodules }}
130
+ # Parse the reference and pull out the semversion information if it is semversion
89
131
- name : Get Semver Details
90
132
shell : bash
91
133
id : semver
92
134
run : |
135
+ # This regex is from the semver page. Yes, I too cry at how big it is, just be glad you didn't have to get it working in bash.
136
+ # https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
93
137
if [[ "${{ inputs.ref }}" =~ ^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))? ]]; then
94
138
echo "issemver=true" >> "$GITHUB_OUTPUT"
95
139
echo "major=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
@@ -101,7 +145,8 @@ jobs:
101
145
else
102
146
echo "issemver=false" >> "$GITHUB_OUTPUT"
103
147
fi
104
- # Setup zig, we use mlugg's setup because it has caching
148
+ # If the reference is semver, modify all zon files to include the version from the reference
149
+ # Mac needs to be done different than windows/linux (see the sed command)
105
150
- name : Process Version Info
106
151
if : steps.semver.outputs.issemver == 'true' && runner.os != 'macOS'
107
152
shell : bash
@@ -112,26 +157,28 @@ jobs:
112
157
shell : bash
113
158
run : |
114
159
find . -name "*.zig.zon" -exec sed -i '' 's/\(.version *= *"\)[^\s]*\(",\)/\1${{ steps.semver.outputs.version }}\2/' {} \;
160
+ # Setup zig, we use mlugg's setup because it has caching
115
161
- name : Setup Zig
116
162
uses : mlugg/setup-zig@v1
117
163
with :
118
164
version : ${{ inputs.zig-version }}
119
165
- name : Build
120
- run : zig build -Doptimize=ReleaseSmall
121
- working-directory : ${{ inputs.working-directory }}
166
+ run : |
167
+ zig build ${{ inputs.zig-args }}
168
+ working-directory : ./${{ inputs.working-directory }}
122
169
- name : Package
123
170
if : ${{ inputs.is-packaged && runner.os == 'macOS' }}
124
171
run : zig build package -- "${{ secrets.downloads-url }}"
172
+ working-directory : ./${{ inputs.working-directory }}
125
173
# We use whether or not an artifact output path is provided and whether
126
174
# or not there is actually anything in that directory to know whether or
127
175
# not there is anything to upload.
128
176
- name : Get Should Upload bash
129
177
id : should-upload
130
178
shell : bash
131
179
run : |
132
- if [[ ! -z "${{ inputs.artifact-output-paths }}" ]] \
133
- && test -n "$(find . -maxdepth 1 \
134
- -name '${{ inputs.artifact-output-paths }}' \
180
+ if [[ ! -z "${{ inputs.artifact-output-path }}" ]] \
181
+ && test -n "$(find ${{ inputs.artifact-output-path }} -maxdepth 1 \
135
182
-print -quit)"; then
136
183
echo "SHOULD_UPLOAD=true" >> $GITHUB_OUTPUT;
137
184
else
@@ -142,8 +189,9 @@ jobs:
142
189
- name : Upload Artifacts
143
190
if : |
144
191
steps.should-upload.outputs.SHOULD_UPLOAD == 'true'
145
- && inputs.github-artifact-name != ''
192
+ && inputs.github-artifact-name != ''
193
+ && ( runner.os == inputs.target-os || inputs.target-os == '' )
146
194
uses : actions/upload-artifact@v4
147
195
with :
148
196
name : ${{ inputs.github-artifact-name }}
149
- path : ${{ inputs.artifact-output-paths }}
197
+ path : ${{ inputs.artifact-output-path }}
0 commit comments