OSDN Git Service

68dea9eb11f61afcaf7832c9e6c9b059f4dccfec
[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@v4
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           vertype=`sed -E -n -e 's/^[[:blank:]]*constexpr[[:blank:]]+VersionStatusType[[:blank:]]+VERSION_STATUS[[:blank:]]*=[[:blank:]]*VersionStatusType:://p' "$verfile" | cut -d ' ' -f 1 | cut -d ';' -f 1`
82           if test x${vertype} == xALPHA ; then
83             version="${version}-Alpha${extra}"
84             tag="${tag}-alpha${extra}"
85           elif test x${vertype} == xBETA ; then
86             version="${version}-Beta${extra}"
87             tag="${tag}-beta${extra}"
88           elif test x${vertype} == xRELEASE_CANDIDATE ; then
89             version="${version}-RC${extra}"
90             tag="${tag}-rc${extra}"
91           fi
92           head=`git rev-parse --verify --short HEAD`
93           version="${version}-${head}"
94           tag="${tag}-${head}"
95           if git diff-index --quiet HEAD ; then
96             true
97           else
98             version="$version"-dirty
99             tag="$tag"-dirty
100           fi
101           echo "version=$version" >> $GITHUB_OUTPUT
102           echo "tag=$tag" >> $GITHUB_OUTPUT
103           prerelease=true
104           echo "prerelease=$prerelease" >> $GITHUB_OUTPUT
105           # Mark anything that isn't a prerelease as a draft.
106           draft=true
107           if test x$prerelease = xtrue ; then
108               draft=false
109           fi
110           echo "draft=$draft" >> $GITHUB_OUTPUT
111
112       # The quoting here may be too simple-minded:  what if there are single
113       # quotes in the steps.*.outputs.* stuff.
114       - name: Create Artifact with Configuration Details
115         run: |
116           echo name= '${{ steps.get_names.outputs.name }}' > $CONFIG_ARTIFACT_PATH
117           echo cap= '${{ steps.get_names.outputs.cap }}' >> $CONFIG_ARTIFACT_PATH
118           echo version= '${{ steps.get_release_vars.outputs.version }}' >> $CONFIG_ARTIFACT_PATH
119           echo tag= '${{ steps.get_release_vars.outputs.tag }}' >> $CONFIG_ARTIFACT_PATH
120           echo prerelease= '${{ steps.get_release_vars.outputs.prerelease }}' >> $CONFIG_ARTIFACT_PATH
121           echo draft= '${{ steps.get_release_vars.outputs.draft }}' >> $CONFIG_ARTIFACT_PATH
122
123       - name: Upload Artifact for Use by Dependent Steps
124         uses: actions/upload-artifact@v4
125         with:
126           name: ${{ env.CONFIG_ARTIFACT }}
127           path: ${{ env.CONFIG_ARTIFACT_PATH }}
128           retention-days: 1
129
130   source:
131     needs: setup
132     name: Source Archive
133     runs-on: ubuntu-latest
134     steps:
135       - name: Download Artifact with Configuration Information
136         uses: actions/download-artifact@v4
137         with:
138           name: ${{ env.CONFIG_ARTIFACT }}
139
140       - name: Extract Configuration Information and Store in Step Outputs
141         id: store_config
142         run: |
143           name=`sed -E -n -e 's/name= //p' $CONFIG_ARTIFACT_PATH`
144           echo "name=$name" >> $GITHUB_OUTPUT
145           version=`sed -E -n -e 's/version= //p' $CONFIG_ARTIFACT_PATH`
146           echo "version=$version" >> $GITHUB_OUTPUT
147
148       - name: Install Build Dependencies
149         run: |
150           sudo apt-get update
151           sudo apt-get install automake autoconf make tar gzip
152
153       - name: Clone Project
154         uses: actions/checkout@v4
155         with:
156           submodules: true
157
158       - name: Create Source Archive
159         id: create_source_archive
160         run: |
161           out="${{ steps.store_config.outputs.name }}"-"${{ steps.store_config.outputs.version }}"
162           echo "archive_file=${out}.tar.gz" >> $GITHUB_OUTPUT
163           ./bootstrap
164           ./configure --disable-japanese --disable-net
165           make distdir
166           mv "${{ steps.store_config.outputs.name }}"-* "$out"
167           tar -cBf - "$out" | gzip -c - >"$out".tar.gz
168
169       - name: Create Artifact with Source Archive Path
170         run: |
171           echo archive_path= '${{ steps.create_source_archive.outputs.archive_file }}' > $SRC_ARTIFACT_PATH
172
173       - name: Upload Artifact with Source Archive Path
174         uses: actions/upload-artifact@v4
175         with:
176           name: ${{ env.SRC_ARTIFACT }}
177           path: ${{ env.SRC_ARTIFACT_PATH }}
178           retention-days: 1
179
180       - name: Upload Source Archive as Artifact
181         uses: actions/upload-artifact@v4
182         with:
183           name: ${{ env.SRC_ARCHIVE_ARTIFACT }}
184           path: ${{ steps.create_source_archive.outputs.archive_file }}
185           retention-days: 1
186
187   mac_en:
188     needs: [setup]
189     name: Mac English
190     runs-on: macos-latest
191     steps:
192       - name: Download Artifact with Configuration Information
193         uses: actions/download-artifact@v4
194         with:
195           name: ${{ env.CONFIG_ARTIFACT }}
196
197       - name: Extract Configuration Information and Store in Step Outputs
198         id: store_config
199         run: |
200           name=`sed -E -n -e 's/name= //p' $CONFIG_ARTIFACT_PATH`
201           echo "name=$name" >> $GITHUB_OUTPUT
202           cap=`sed -E -n -e 's/cap= //p' $CONFIG_ARTIFACT_PATH`
203           echo "cap=$cap" >> $GITHUB_OUTPUT
204           version=`sed -E -n -e 's/version= //p' $CONFIG_ARTIFACT_PATH`
205           echo "version=$version" >> $GITHUB_OUTPUT
206
207       - name: Clone Project
208         uses: actions/checkout@v4
209         with:
210           submodules: true
211
212       # Requires automake and autoconf; install those via homebrew (available
213       # by default).
214       - name: Install Build Dependencies
215         run: |
216           brew install m4
217           brew install autoconf
218           brew install automake
219
220       - name: Create Mac English Archive
221         id: create_mac_en_archive
222         run: |
223           if test -n `echo "${{ env.SDK_OVERRIDE }}" | tr -d ' \t\r\n'` ; then
224             SDKROOT=`echo "${{ env.SDK_OVERRIDE }}" | tr -d ' \t\r\n'`
225             export SDKROOT
226           fi
227           ./bootstrap
228           CFLAGS=""
229           CXXFLAGS=""
230           OBJCXXFLAGS=""
231           LDFLAGS=""
232           DEPENDENCY_TRACKING=""
233           if test -n `echo "${{ env.UNIVERSAL_ARCHS }}" | tr -d ' \t\r\n'` ; then
234             DEPENDENCY_TRACKING="--disable-dependency-tracking --disable-pch"
235             # Include what configure normally infers for the compiler flags.
236             # Without -O2, the generated executables take painfully long to
237             # read the data files.
238             CFLAGS="$CFLAGS -g -O2"
239             CXXFLAGS="$CXXFLAGS -g -O2"
240             OBJCXXFLAGS="$OBJCXXFLAGS -g -O2"
241             for arch in ${{ env.UNIVERSAL_ARCHS }} ; do
242               option="-arch $arch"
243               CFLAGS="$CFLAGS $option"
244               CXXFLAGS="$CXXFLAGS $option"
245               OBJCXXFLAGS="$OBJCXXFLAGS $option"
246               LDFLAGS="$LDFLAGS $option"
247             done
248             echo "Performing a univeral build:"
249             echo "  CFLAGS = $CFLAGS"
250             echo "  CXXFLAGS = $CXXFLAGS"
251             echo "  OBJCXXFLAGS = $OBJCXXFLAGS"
252             echo "  LDFLAGS = $LDFLAGS"
253           fi
254           env CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" \
255             OBJCXXFLAGS="$OBJCXXFLAGS" LDFLAGS="$LDFLAGS" \
256             ./configure --enable-cocoa --disable-japanese $DEPENDENCY_TRACKING
257           make install
258           mkdir disttemp
259           mv "${{ steps.store_config.outputs.name }}".app disttemp
260           hdiutil create -quiet -volname "${{ steps.store_config.outputs.cap }}-${{ steps.store_config.outputs.version }}-English" -srcfolder disttemp disttemp.dmg
261           archive_prefix="${{ steps.store_config.outputs.cap }}-${{ steps.store_config.outputs.version }}-English"
262           echo "archive_file=${archive_prefix}.dmg" >> $GITHUB_OUTPUT
263           hdiutil convert disttemp.dmg -quiet -format UDZO -imagekey zlib-level=6 -o "${archive_prefix}.dmg"
264
265       - name: Create Artifact with Mac English Archive Path
266         run: |
267           echo archive_path= '${{ steps.create_mac_en_archive.outputs.archive_file }}' > $MAC_ENGLISH_ARTIFACT_PATH
268
269       - name: Upload Artifact with Mac English Archive Path
270         uses: actions/upload-artifact@v4
271         with:
272           name: ${{ env.MAC_ENGLISH_ARTIFACT }}
273           path: ${{ env.MAC_ENGLISH_ARTIFACT_PATH }}
274           retention-days: 1
275
276       - name: Upload Mac English Archive as Artifact
277         uses: actions/upload-artifact@v4
278         with:
279           name: ${{ env.MAC_ENGLISH_ARCHIVE_ARTIFACT }}
280           path: ${{ steps.create_mac_en_archive.outputs.archive_file }}
281           retention-days: 1
282
283   mac_ja:
284     needs: [setup]
285     name: Mac Japanese
286     runs-on: macos-latest
287     steps:
288       - name: Download Artifact with Configuration Information
289         uses: actions/download-artifact@v4
290         with:
291           name: ${{ env.CONFIG_ARTIFACT }}
292
293       - name: Extract Configuration Information and Store in Step Outputs
294         id: store_config
295         run: |
296           name=`sed -E -n -e 's/name= //p' $CONFIG_ARTIFACT_PATH`
297           echo "name=$name" >> $GITHUB_OUTPUT
298           cap=`sed -E -n -e 's/cap= //p' $CONFIG_ARTIFACT_PATH`
299           echo "cap=$cap" >> $GITHUB_OUTPUT
300           version=`sed -E -n -e 's/version= //p' $CONFIG_ARTIFACT_PATH`
301           echo "version=$version" >> $GITHUB_OUTPUT
302
303       - name: Clone Project
304         uses: actions/checkout@v4
305         with:
306           submodules: true
307
308       # Requires automake, autoconf, and nkf; install those via homebrew
309       # (available by default).
310       - name: Install Build Dependencies
311         run: |
312           brew install m4
313           brew install autoconf
314           brew install automake
315           brew install nkf
316
317       - name: Create Mac Japanese Archive
318         id: create_mac_ja_archive
319         run: |
320           if test -n `echo "${{ env.SDK_OVERRIDE }}" | tr -d ' \t\r\n'` ; then
321             SDKROOT=`echo "${{ env.SDK_OVERRIDE }}" | tr -d ' \t\r\n'`
322             export SDKROOT
323           fi
324           ./bootstrap
325           CFLAGS=""
326           CXXFLAGS=""
327           OBJCXXFLAGS=""
328           LDFLAGS=""
329           DEPENDENCY_TRACKING=""
330           if test -n `echo "${{ env.UNIVERSAL_ARCHS }}" | tr -d ' \t\r\n'` ; then
331             DEPENDENCY_TRACKING="--disable-dependency-tracking --disable-pch"
332             # Include what configure normally infers for the compiler flags.
333             # Without -O2, the generated executables take painfully long to
334             # read the data files.
335             CFLAGS="$CFLAGS -g -O2"
336             CXXFLAGS="$CXXFLAGS -g -O2"
337             OBJCXXFLAGS="$OBJCXXFLAGS -g -O2"
338             for arch in ${{ env.UNIVERSAL_ARCHS }} ; do
339               option="-arch $arch"
340               CFLAGS="$CFLAGS $option"
341               CXXFLAGS="$CXXFLAGS $option"
342               OBJCXXFLAGS="$OBJCXXFLAGS $option"
343               LDFLAGS="$LDFLAGS $option"
344             done
345             echo "Performing a univeral build:"
346             echo "  CFLAGS = $CFLAGS"
347             echo "  CXXFLAGS = $CXXFLAGS"
348             echo "  OBJCXXFLAGS = $OBJCXXFLAGS"
349             echo "  LDFLAGS = $LDFLAGS"
350           fi
351           env CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" \
352             OBJCXXFLAGS="$OBJCXXFLAGS" LDFLAGS="$LDFLAGS" \
353             ./configure --enable-cocoa $DEPENDENCY_TRACKING
354           make install
355           mkdir disttemp
356           mv "${{ steps.store_config.outputs.name }}".app disttemp
357           hdiutil create -quiet -volname "${{ steps.store_config.outputs.cap }}-${{ steps.store_config.outputs.version}}-Japanese" -srcfolder disttemp disttemp.dmg
358           archive_prefix="${{ steps.store_config.outputs.cap }}-${{ steps.store_config.outputs.version }}-Japanese"
359           echo "archive_file=${archive_prefix}.dmg" >> $GITHUB_OUTPUT
360           hdiutil convert disttemp.dmg -quiet -format UDZO -imagekey zlib-level=6 -o "${archive_prefix}.dmg"
361
362       - name: Create Artifact with Mac Japanese Archive Path
363         run: |
364           echo archive_path= '${{ steps.create_mac_ja_archive.outputs.archive_file }}' > $MAC_JAPANESE_ARTIFACT_PATH
365
366       - name: Upload Artifact with Mac Japanese Archive Path
367         uses: actions/upload-artifact@v4
368         with:
369           name: ${{ env.MAC_JAPANESE_ARTIFACT }}
370           path: ${{ env.MAC_JAPANESE_ARTIFACT_PATH }}
371           retention-days: 1
372
373       - name: Upload Mac Japanese Archive as Artifact
374         uses: actions/upload-artifact@v4
375         with:
376           name: ${{ env.MAC_JAPANESE_ARCHIVE_ARTIFACT }}
377           path: ${{ steps.create_mac_ja_archive.outputs.archive_file }}
378           retention-days: 1
379
380   release:
381     needs: [ setup, source, mac_en, mac_ja ]
382     name: Create GitHub Release
383     runs-on: ubuntu-latest
384     steps:
385       - name: Download Artifact with Configuration Information
386         uses: actions/download-artifact@v4
387         with:
388           name: ${{ env.CONFIG_ARTIFACT }}
389
390       - name: Extract Configuration Information and Store in Step Outputs
391         id: store_config
392         run: |
393           version=`sed -E -n -e 's/version= //p' $CONFIG_ARTIFACT_PATH`
394           echo "version=$version" >> $GITHUB_OUTPUT
395           tag=`sed -E -n -e 's/tag= //p' $CONFIG_ARTIFACT_PATH`
396           echo "tag=$tag" >> $GITHUB_OUTPUT
397           prerelease=`sed -E -n -e 's/prerelease= //p' $CONFIG_ARTIFACT_PATH`
398           echo "prerelease=$prerelease" >> $GITHUB_OUTPUT
399           draft=`sed -E -n -e 's/draft= //p' $CONFIG_ARTIFACT_PATH`
400           echo "draft=$draft" >> $GITHUB_OUTPUT
401
402       - name: Download Artifact with Source Archive Path
403         uses: actions/download-artifact@v4
404         with:
405           name: ${{ env.SRC_ARTIFACT }}
406
407       - name: Extract Source Archive Path and Store in Step Outputs
408         id: store_src
409         run: |
410           archive_path=`sed -E -n -e 's/archive_path= //p' $SRC_ARTIFACT_PATH`
411           echo "archive_path=$archive_path" >> $GITHUB_OUTPUT
412
413       - name: Download Artifact with Source Archive
414         uses: actions/download-artifact@v4
415         with:
416           name: ${{ env.SRC_ARCHIVE_ARTIFACT }}
417
418       - name: Download Artifact with Mac English Archive Path
419         uses: actions/download-artifact@v4
420         with:
421           name: ${{ env.MAC_ENGLISH_ARTIFACT }}
422
423       - name: Extract Mac English Archive Path and Store in Step Outputs
424         id: store_mac_en
425         run: |
426           archive_path=`sed -E -n -e 's/archive_path= //p' $MAC_ENGLISH_ARTIFACT_PATH`
427           echo "archive_path=$archive_path" >> $GITHUB_OUTPUT
428
429       - name: Download Artifact with Mac English Archive
430         uses: actions/download-artifact@v4
431         with:
432           name: ${{ env.MAC_ENGLISH_ARCHIVE_ARTIFACT }}
433
434       - name: Download Artifact with Mac Japanese Archive Path
435         uses: actions/download-artifact@v4
436         with:
437           name: ${{ env.MAC_JAPANESE_ARTIFACT }}
438
439       - name: Extract Mac Japanese Archive Path and Store in Step Outputs
440         id: store_mac_ja
441         run: |
442           archive_path=`sed -E -n -e 's/archive_path= //p' $MAC_JAPANESE_ARTIFACT_PATH`
443           echo "archive_path=$archive_path" >> $GITHUB_OUTPUT
444
445       - name: Download Artifact with Mac Japanese Archive
446         uses: actions/download-artifact@v4
447         with:
448           name: ${{ env.MAC_JAPANESE_ARCHIVE_ARTIFACT }}
449
450       - name: Populate Release
451         uses: softprops/action-gh-release@v1
452         with:
453           tag_name: "${{ steps.store_config.outputs.tag }}"
454           name: ${{ steps.store_config.outputs.version }}
455           target_commitish: ${{ github.sha }}
456           draft: ${{ steps.store_config.outputs.draft }}
457           prerelease: ${{ steps.store_config.outputs.prerelease }}
458           files: |
459             ${{ steps.store_src.outputs.archive_path }}
460             ${{ steps.store_mac_en.outputs.archive_path }}
461             ${{ steps.store_mac_ja.outputs.archive_path }}
462           token: ${{ secrets.GITHUB_TOKEN }}