OSDN Git Service

Fix up workflows for libcurl dependence
[hengbandforosx/hengbandosx.git] / .github / workflows / release.yaml
1 name: create-github-release
2
3 on:
4   push:
5     branches: [ macos-develop ]
6
7 env:
8     # If set and is not empty or all whitespace, this should be the list of
9     # architectures to build into a universal binary.  If not set, empty, or
10     # all whitespace, the default architecture for the combination of runner
11     # and hardware will be used.
12     UNIVERSAL_ARCHS: x86_64 arm64
13     # If set and is not empty or all whitespace, sets the name of the SDK to
14     # use.  Otherwise the default SDK for the runner will be used.  Want an
15     # SDK that can build all the architectures in UNIVERSAL_ARCHS.  For valid
16     # values of the sdk name, look at the xcrun man page.
17     #SDK_OVERRIDE: macosx11.3
18     # Used as the name when uploading or downloading the artifact for passing
19     # configuration data from the Setup job to those dependent on it.
20     CONFIG_ARTIFACT: release-config
21     # Used as the path for the file with the configuration data passed from
22     # the Setup job to those dependent on it.
23     CONFIG_ARTIFACT_PATH: release-config.txt
24     # Used as the name when uploading or downloading the artifact for passing
25     # the name of the source archive.
26     SRC_ARTIFACT: release-src
27     # Used as the path for the file with the name of the source archive in it.
28     SRC_ARTIFACT_PATH: release-src.txt
29     # Used as the name when uploading or downloading the artifact holding
30     # the source archive.
31     SRC_ARCHIVE_ARTIFACT: release-src-archive
32     # Used as the name when uploading or downloading the artifact for passing
33     # the name of the Mac archive for the English version.
34     MAC_ENGLISH_ARTIFACT: release-mac-en
35     # Used as the path for the file with the name of the Mac archive for the
36     # English version in it.
37     MAC_ENGLISH_ARTIFACT_PATH: release-mac-en.txt
38     # Used as the name when uploading or downloading the artifact holding
39     # the Mac archive for the English version.
40     MAC_ENGLISH_ARCHIVE_ARTIFACT: release-mac-en-archive
41     # Used as the name when uploading or downloading the artifact for passing
42     # the name of the Mac archive for the English version.
43     MAC_JAPANESE_ARTIFACT: release-mac-ja
44     # Used as the path for the file with the name of the Mac archive for the
45     # English version in it.
46     MAC_JAPANESE_ARTIFACT_PATH: release-mac-ja.txt
47     # Used as the name when uploading or downloading the artifact holding
48     # the Mac archive for the English version.
49     MAC_JAPANESE_ARCHIVE_ARTIFACT: release-mac-ja-archive
50
51 jobs:
52   setup:
53     name: Setup
54     runs-on: ubuntu-latest
55     steps:
56       # Need commit history and tags to get the version so use 0 for
57       # fetch-depth.  Don't need the submodule(s) here.
58       - name: Clone Project
59         uses: actions/checkout@v3
60         with:
61           fetch-depth: 0
62
63       - name: Extract Names from configure.ac
64         id: get_names
65         run: |
66           name=`sed -E -n -e 's/^[[:blank:]]*AC_INIT\([[:blank:]]*\\[?//p' configure.ac | tail -1 | cut -d ']' -f 1 | cut -d ',' -f 1`
67           echo "name=$name" >> $GITHUB_OUTPUT
68           cap=`echo $name | sed -E -e 's/^a/A/' -e 's/^b/B/' -e 's/^c/C/' -e 's/^d/D/' -e 's/^e/E/' -e 's/^f/F/' -e 's/^g/G/' -e 's/^h/H/' -e 's/^i/I/' -e 's/^j/J/' -e 's/^k/K/' -e 's/^l/L/' -e 's/^m/M/' -e 's/^n/N/' -e 's/^o/O/' -e 's/^p/P/' -e 's/^q/Q/' -e 's/^r/R/' -e 's/^s/S/' -e 's/^t/T/' -e 's/^u/U/' -e 's/^v/V/' -e 's/^w/W/' -e 's/^x/X/' -e 's/^y/Y/' -e 's/^z/Z/'`
69           echo "cap=$cap" >> $GITHUB_OUTPUT
70
71       - name: Set Release Version
72         id: get_release_vars
73         run: |
74           verfile=src/system/angband-version.h
75           major=`sed -E -n -e 's/^[[:blank:]]*#define[[:blank:]]+H_VER_MAJOR[[:blank:]]+//p' "$verfile" | cut -d ' ' -f 1 | cut -f 1 | cut -d '/' -f 1`
76           minor=`sed -E -n -e 's/^[[:blank:]]*#define[[:blank:]]+H_VER_MINOR[[:blank:]]+//p' "$verfile" | cut -d ' ' -f 1 | cut -f 1 | cut -d '/' -f 1`
77           patch=`sed -E -n -e 's/^[[:blank:]]*#define[[:blank:]]+H_VER_PATCH[[:blank:]]+//p' "$verfile" | cut -d ' ' -f 1 | cut -f 1 | cut -d '/' -f 1`
78           extra=`sed -E -n -e 's/^[[:blank:]]*#define[[:blank:]]+H_VER_EXTRA[[:blank:]]+//p' "$verfile" | cut -d ' ' -f 1 | cut -f 1 | cut -d '/' -f 1`
79           version="$major"."$minor"."$patch"
80           tag=vauto"$version"
81           if test x$extra != x0 ; then
82             version="${version}-Alpha${extra}"
83             tag="${tag}-alpha${extra}"
84           fi
85           head=`git rev-parse --verify --short HEAD`
86           version="${version}-${head}"
87           tag="${tag}-${head}"
88           if git diff-index --quiet HEAD ; then
89             true
90           else
91             version="$version"-dirty
92             tag="$tag"-dirty
93           fi
94           echo "version=$version" >> $GITHUB_OUTPUT
95           echo "tag=$tag" >> $GITHUB_OUTPUT
96           prerelease=true
97           echo "prerelease=$prerelease" >> $GITHUB_OUTPUT
98           # Mark anything that isn't a prerelease as a draft.
99           draft=true
100           if test x$prerelease = xtrue ; then
101               draft=false
102           fi
103           echo "draft=$draft" >> $GITHUB_OUTPUT
104
105       # The quoting here may be too simple-minded:  what if there are single
106       # quotes in the steps.*.outputs.* stuff.
107       - name: Create Artifact with Configuration Details
108         run: |
109           echo name= '${{ steps.get_names.outputs.name }}' > $CONFIG_ARTIFACT_PATH
110           echo cap= '${{ steps.get_names.outputs.cap }}' >> $CONFIG_ARTIFACT_PATH
111           echo version= '${{ steps.get_release_vars.outputs.version }}' >> $CONFIG_ARTIFACT_PATH
112           echo tag= '${{ steps.get_release_vars.outputs.tag }}' >> $CONFIG_ARTIFACT_PATH
113           echo prerelease= '${{ steps.get_release_vars.outputs.prerelease }}' >> $CONFIG_ARTIFACT_PATH
114           echo draft= '${{ steps.get_release_vars.outputs.draft }}' >> $CONFIG_ARTIFACT_PATH
115
116       - name: Upload Artifact for Use by Dependent Steps
117         uses: actions/upload-artifact@v3
118         with:
119           name: ${{ env.CONFIG_ARTIFACT }}
120           path: ${{ env.CONFIG_ARTIFACT_PATH }}
121           retention-days: 1
122
123   source:
124     needs: setup
125     name: Source Archive
126     runs-on: ubuntu-latest
127     steps:
128       - name: Download Artifact with Configuration Information
129         uses: actions/download-artifact@v3
130         with:
131           name: ${{ env.CONFIG_ARTIFACT }}
132
133       - name: Extract Configuration Information and Store in Step Outputs
134         id: store_config
135         run: |
136           name=`sed -E -n -e 's/name= //p' $CONFIG_ARTIFACT_PATH`
137           echo "name=$name" >> $GITHUB_OUTPUT
138           version=`sed -E -n -e 's/version= //p' $CONFIG_ARTIFACT_PATH`
139           echo "version=$version" >> $GITHUB_OUTPUT
140
141       - name: Install Build Dependencies
142         run: |
143           sudo apt-get update
144           sudo apt-get install automake autoconf make tar gzip
145
146       - name: Clone Project
147         uses: actions/checkout@v3
148         with:
149           submodules: true
150
151       - name: Create Source Archive
152         id: create_source_archive
153         run: |
154           out="${{ steps.store_config.outputs.name }}"-"${{ steps.store_config.outputs.version }}"
155           echo "archive_file=${out}.tar.gz" >> $GITHUB_OUTPUT
156           ./bootstrap
157           ./configure --disable-japanese --disable-net
158           make distdir
159           mv "${{ steps.store_config.outputs.name }}"-* "$out"
160           tar -cBf - "$out" | gzip -c - >"$out".tar.gz
161
162       - name: Create Artifact with Source Archive Path
163         run: |
164           echo archive_path= '${{ steps.create_source_archive.outputs.archive_file }}' > $SRC_ARTIFACT_PATH
165
166       - name: Upload Artifact with Source Archive Path
167         uses: actions/upload-artifact@v3
168         with:
169           name: ${{ env.SRC_ARTIFACT }}
170           path: ${{ env.SRC_ARTIFACT_PATH }}
171           retention-days: 1
172
173       - name: Upload Source Archive as Artifact
174         uses: actions/upload-artifact@v3
175         with:
176           name: ${{ env.SRC_ARCHIVE_ARTIFACT }}
177           path: ${{ steps.create_source_archive.outputs.archive_file }}
178           retention-days: 1
179
180   mac_en:
181     needs: [setup]
182     name: Mac English
183     runs-on: macos-latest
184     steps:
185       - name: Download Artifact with Configuration Information
186         uses: actions/download-artifact@v3
187         with:
188           name: ${{ env.CONFIG_ARTIFACT }}
189
190       - name: Extract Configuration Information and Store in Step Outputs
191         id: store_config
192         run: |
193           name=`sed -E -n -e 's/name= //p' $CONFIG_ARTIFACT_PATH`
194           echo "name=$name" >> $GITHUB_OUTPUT
195           cap=`sed -E -n -e 's/cap= //p' $CONFIG_ARTIFACT_PATH`
196           echo "cap=$cap" >> $GITHUB_OUTPUT
197           version=`sed -E -n -e 's/version= //p' $CONFIG_ARTIFACT_PATH`
198           echo "version=$version" >> $GITHUB_OUTPUT
199
200       - name: Clone Project
201         uses: actions/checkout@v3
202         with:
203           submodules: true
204
205       # Requires automake and autoconf; install those via homebrew (available
206       # by default).  Use autoconf 2.69 since autoconf 2.71 does not work well
207       # with the version of m4 (GNU M4 1.4.6) included with macOS 11 and 12.
208       - name: Install Build Dependencies
209         run: |
210           brew install m4
211           brew install autoconf@2.69
212           brew install automake
213
214       - name: Create Mac English Archive
215         id: create_mac_en_archive
216         run: |
217           if test -n `echo "${{ env.SDK_OVERRIDE }}" | tr -d ' \t\r\n'` ; then
218             SDKROOT=`echo "${{ env.SDK_OVERRIDE }}" | tr -d ' \t\r\n'`
219             export SDKROOT
220           fi
221           PATH=/usr/local/opt/autoconf@2.69/bin:"$PATH"
222           ./bootstrap
223           CFLAGS=""
224           CXXFLAGS=""
225           OBJCXXFLAGS=""
226           LDFLAGS=""
227           DEPENDENCY_TRACKING=""
228           if test -n `echo "${{ env.UNIVERSAL_ARCHS }}" | tr -d ' \t\r\n'` ; then
229             DEPENDENCY_TRACKING="--disable-dependency-tracking --disable-pch"
230             # Include what configure normally infers for the compiler flags.
231             # Without -O2, the generated executables take painfully long to
232             # read the data files.
233             CFLAGS="$CFLAGS -g -O2"
234             CXXFLAGS="$CXXFLAGS -g -O2"
235             OBJCXXFLAGS="$OBJCXXFLAGS -g -O2"
236             for arch in ${{ env.UNIVERSAL_ARCHS }} ; do
237               option="-arch $arch"
238               CFLAGS="$CFLAGS $option"
239               CXXFLAGS="$CXXFLAGS $option"
240               OBJCXXFLAGS="$OBJCXXFLAGS $option"
241               LDFLAGS="$LDFLAGS $option"
242             done
243             echo "Performing a univeral build:"
244             echo "  CFLAGS = $CFLAGS"
245             echo "  CXXFLAGS = $CXXFLAGS"
246             echo "  OBJCXXFLAGS = $OBJCXXFLAGS"
247             echo "  LDFLAGS = $LDFLAGS"
248           fi
249           env CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" \
250             OBJCXXFLAGS="$OBJCXXFLAGS" LDFLAGS="$LDFLAGS" \
251             ./configure --enable-cocoa --disable-japanese $DEPENDENCY_TRACKING
252           make install
253           mkdir disttemp
254           mv "${{ steps.store_config.outputs.name }}".app disttemp
255           hdiutil create -quiet -volname "${{ steps.store_config.outputs.cap }}-${{ steps.store_config.outputs.version }}-English" -srcfolder disttemp disttemp.dmg
256           archive_prefix="${{ steps.store_config.outputs.cap }}-${{ steps.store_config.outputs.version }}-English"
257           echo "archive_file=${archive_prefix}.dmg" >> $GITHUB_OUTPUT
258           hdiutil convert disttemp.dmg -quiet -format UDZO -imagekey zlib-level=6 -o "${archive_prefix}.dmg"
259
260       - name: Create Artifact with Mac English Archive Path
261         run: |
262           echo archive_path= '${{ steps.create_mac_en_archive.outputs.archive_file }}' > $MAC_ENGLISH_ARTIFACT_PATH
263
264       - name: Upload Artifact with Mac English Archive Path
265         uses: actions/upload-artifact@v3
266         with:
267           name: ${{ env.MAC_ENGLISH_ARTIFACT }}
268           path: ${{ env.MAC_ENGLISH_ARTIFACT_PATH }}
269           retention-days: 1
270
271       - name: Upload Mac English Archive as Artifact
272         uses: actions/upload-artifact@v3
273         with:
274           name: ${{ env.MAC_ENGLISH_ARCHIVE_ARTIFACT }}
275           path: ${{ steps.create_mac_en_archive.outputs.archive_file }}
276           retention-days: 1
277
278   mac_ja:
279     needs: [setup]
280     name: Mac Japanese
281     runs-on: macos-latest
282     steps:
283       - name: Download Artifact with Configuration Information
284         uses: actions/download-artifact@v3
285         with:
286           name: ${{ env.CONFIG_ARTIFACT }}
287
288       - name: Extract Configuration Information and Store in Step Outputs
289         id: store_config
290         run: |
291           name=`sed -E -n -e 's/name= //p' $CONFIG_ARTIFACT_PATH`
292           echo "name=$name" >> $GITHUB_OUTPUT
293           cap=`sed -E -n -e 's/cap= //p' $CONFIG_ARTIFACT_PATH`
294           echo "cap=$cap" >> $GITHUB_OUTPUT
295           version=`sed -E -n -e 's/version= //p' $CONFIG_ARTIFACT_PATH`
296           echo "version=$version" >> $GITHUB_OUTPUT
297
298       - name: Clone Project
299         uses: actions/checkout@v3
300         with:
301           submodules: true
302
303       # Requires automake, autoconf, and nkf; install those via homebrew
304       # (available by default).  Use autoconf 2.69 since autoconf 2.71 does
305       # not work well with the version of m4 (GNU M4 1.4.6) included with
306       # macOS 11 and 12.
307       - name: Install Build Dependencies
308         run: |
309           brew install m4
310           brew install autoconf@2.69
311           brew install automake
312           brew install nkf
313
314       - name: Create Mac Japanese Archive
315         id: create_mac_ja_archive
316         run: |
317           if test -n `echo "${{ env.SDK_OVERRIDE }}" | tr -d ' \t\r\n'` ; then
318             SDKROOT=`echo "${{ env.SDK_OVERRIDE }}" | tr -d ' \t\r\n'`
319             export SDKROOT
320           fi
321           PATH=/usr/local/opt/autoconf@2.69/bin:"$PATH"
322           ./bootstrap
323           CFLAGS=""
324           CXXFLAGS=""
325           OBJCXXFLAGS=""
326           LDFLAGS=""
327           DEPENDENCY_TRACKING=""
328           if test -n `echo "${{ env.UNIVERSAL_ARCHS }}" | tr -d ' \t\r\n'` ; then
329             DEPENDENCY_TRACKING="--disable-dependency-tracking --disable-pch"
330             # Include what configure normally infers for the compiler flags.
331             # Without -O2, the generated executables take painfully long to
332             # read the data files.
333             CFLAGS="$CFLAGS -g -O2"
334             CXXFLAGS="$CXXFLAGS -g -O2"
335             OBJCXXFLAGS="$OBJCXXFLAGS -g -O2"
336             for arch in ${{ env.UNIVERSAL_ARCHS }} ; do
337               option="-arch $arch"
338               CFLAGS="$CFLAGS $option"
339               CXXFLAGS="$CXXFLAGS $option"
340               OBJCXXFLAGS="$OBJCXXFLAGS $option"
341               LDFLAGS="$LDFLAGS $option"
342             done
343             echo "Performing a univeral build:"
344             echo "  CFLAGS = $CFLAGS"
345             echo "  CXXFLAGS = $CXXFLAGS"
346             echo "  OBJCXXFLAGS = $OBJCXXFLAGS"
347             echo "  LDFLAGS = $LDFLAGS"
348           fi
349           env CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" \
350             OBJCXXFLAGS="$OBJCXXFLAGS" LDFLAGS="$LDFLAGS" \
351             ./configure --enable-cocoa $DEPENDENCY_TRACKING
352           make install
353           mkdir disttemp
354           mv "${{ steps.store_config.outputs.name }}".app disttemp
355           hdiutil create -quiet -volname "${{ steps.store_config.outputs.cap }}-${{ steps.store_config.outputs.version}}-Japanese" -srcfolder disttemp disttemp.dmg
356           archive_prefix="${{ steps.store_config.outputs.cap }}-${{ steps.store_config.outputs.version }}-Japanese"
357           echo "archive_file=${archive_prefix}.dmg" >> $GITHUB_OUTPUT
358           hdiutil convert disttemp.dmg -quiet -format UDZO -imagekey zlib-level=6 -o "${archive_prefix}.dmg"
359
360       - name: Create Artifact with Mac Japanese Archive Path
361         run: |
362           echo archive_path= '${{ steps.create_mac_ja_archive.outputs.archive_file }}' > $MAC_JAPANESE_ARTIFACT_PATH
363
364       - name: Upload Artifact with Mac Japanese Archive Path
365         uses: actions/upload-artifact@v3
366         with:
367           name: ${{ env.MAC_JAPANESE_ARTIFACT }}
368           path: ${{ env.MAC_JAPANESE_ARTIFACT_PATH }}
369           retention-days: 1
370
371       - name: Upload Mac Japanese Archive as Artifact
372         uses: actions/upload-artifact@v3
373         with:
374           name: ${{ env.MAC_JAPANESE_ARCHIVE_ARTIFACT }}
375           path: ${{ steps.create_mac_ja_archive.outputs.archive_file }}
376           retention-days: 1
377
378   release:
379     needs: [ setup, source, mac_en, mac_ja ]
380     name: Create GitHub Release
381     runs-on: ubuntu-latest
382     steps:
383       - name: Download Artifact with Configuration Information
384         uses: actions/download-artifact@v3
385         with:
386           name: ${{ env.CONFIG_ARTIFACT }}
387
388       - name: Extract Configuration Information and Store in Step Outputs
389         id: store_config
390         run: |
391           version=`sed -E -n -e 's/version= //p' $CONFIG_ARTIFACT_PATH`
392           echo "version=$version" >> $GITHUB_OUTPUT
393           tag=`sed -E -n -e 's/tag= //p' $CONFIG_ARTIFACT_PATH`
394           echo "tag=$tag" >> $GITHUB_OUTPUT
395           prerelease=`sed -E -n -e 's/prerelease= //p' $CONFIG_ARTIFACT_PATH`
396           echo "prerelease=$prerelease" >> $GITHUB_OUTPUT
397           draft=`sed -E -n -e 's/draft= //p' $CONFIG_ARTIFACT_PATH`
398           echo "draft=$draft" >> $GITHUB_OUTPUT
399
400       - name: Download Artifact with Source Archive Path
401         uses: actions/download-artifact@v3
402         with:
403           name: ${{ env.SRC_ARTIFACT }}
404
405       - name: Extract Source Archive Path and Store in Step Outputs
406         id: store_src
407         run: |
408           archive_path=`sed -E -n -e 's/archive_path= //p' $SRC_ARTIFACT_PATH`
409           echo "archive_path=$archive_path" >> $GITHUB_OUTPUT
410
411       - name: Download Artifact with Source Archive
412         uses: actions/download-artifact@v3
413         with:
414           name: ${{ env.SRC_ARCHIVE_ARTIFACT }}
415
416       - name: Download Artifact with Mac English Archive Path
417         uses: actions/download-artifact@v3
418         with:
419           name: ${{ env.MAC_ENGLISH_ARTIFACT }}
420
421       - name: Extract Mac English Archive Path and Store in Step Outputs
422         id: store_mac_en
423         run: |
424           archive_path=`sed -E -n -e 's/archive_path= //p' $MAC_ENGLISH_ARTIFACT_PATH`
425           echo "archive_path=$archive_path" >> $GITHUB_OUTPUT
426
427       - name: Download Artifact with Mac English Archive
428         uses: actions/download-artifact@v3
429         with:
430           name: ${{ env.MAC_ENGLISH_ARCHIVE_ARTIFACT }}
431
432       - name: Download Artifact with Mac Japanese Archive Path
433         uses: actions/download-artifact@v3
434         with:
435           name: ${{ env.MAC_JAPANESE_ARTIFACT }}
436
437       - name: Extract Mac Japanese Archive Path and Store in Step Outputs
438         id: store_mac_ja
439         run: |
440           archive_path=`sed -E -n -e 's/archive_path= //p' $MAC_JAPANESE_ARTIFACT_PATH`
441           echo "archive_path=$archive_path" >> $GITHUB_OUTPUT
442
443       - name: Download Artifact with Mac Japanese Archive
444         uses: actions/download-artifact@v3
445         with:
446           name: ${{ env.MAC_JAPANESE_ARCHIVE_ARTIFACT }}
447
448       - name: Populate Release
449         uses: softprops/action-gh-release@v1
450         with:
451           tag_name: "${{ steps.store_config.outputs.tag }}"
452           name: ${{ steps.store_config.outputs.version }}
453           target_commitish: ${{ github.sha }}
454           draft: ${{ steps.store_config.outputs.draft }}
455           prerelease: ${{ steps.store_config.outputs.prerelease }}
456           files: |
457             ${{ steps.store_src.outputs.archive_path }}
458             ${{ steps.store_mac_en.outputs.archive_path }}
459             ${{ steps.store_mac_ja.outputs.archive_path }}
460           token: ${{ secrets.GITHUB_TOKEN }}