OSDN Git Service

253cfc587a0fbbe2b24c410c761250e16c09b656
[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           n_name=`find . -maxdepth 1 -type d -name "${{ steps.store.config.outputs.name }}"'-*' -print | wc -l`
167           name=`find . -maxdepth 1 -type d -name "${{ steps.store.config.outputs.name }}"'-*' -print`
168           test x"$n_name" != x1 || exit 1
169           test x"$name" == x"$out" || mv "$name" "$out"
170           tar -cBf - "$out" | gzip -c - >"$out".tar.gz
171
172       - name: Create Artifact with Source Archive Path
173         run: |
174           echo archive_path= '${{ steps.create_source_archive.outputs.archive_file }}' > $SRC_ARTIFACT_PATH
175
176       - name: Upload Artifact with Source Archive Path
177         uses: actions/upload-artifact@v4
178         with:
179           name: ${{ env.SRC_ARTIFACT }}
180           path: ${{ env.SRC_ARTIFACT_PATH }}
181           retention-days: 1
182
183       - name: Upload Source Archive as Artifact
184         uses: actions/upload-artifact@v4
185         with:
186           name: ${{ env.SRC_ARCHIVE_ARTIFACT }}
187           path: ${{ steps.create_source_archive.outputs.archive_file }}
188           retention-days: 1
189
190   mac_en:
191     needs: [setup]
192     name: Mac English
193     runs-on: macos-latest
194     steps:
195       - name: Download Artifact with Configuration Information
196         uses: actions/download-artifact@v4
197         with:
198           name: ${{ env.CONFIG_ARTIFACT }}
199
200       - name: Extract Configuration Information and Store in Step Outputs
201         id: store_config
202         run: |
203           name=`sed -E -n -e 's/name= //p' $CONFIG_ARTIFACT_PATH`
204           echo "name=$name" >> $GITHUB_OUTPUT
205           cap=`sed -E -n -e 's/cap= //p' $CONFIG_ARTIFACT_PATH`
206           echo "cap=$cap" >> $GITHUB_OUTPUT
207           version=`sed -E -n -e 's/version= //p' $CONFIG_ARTIFACT_PATH`
208           echo "version=$version" >> $GITHUB_OUTPUT
209
210       - name: Clone Project
211         uses: actions/checkout@v4
212         with:
213           submodules: true
214
215       # Requires automake and autoconf; install those via homebrew (available
216       # by default).
217       - name: Install Build Dependencies
218         run: |
219           brew install m4
220           brew install autoconf
221           brew install automake
222
223       - name: Create Mac English Archive
224         id: create_mac_en_archive
225         run: |
226           if test -n `echo "${{ env.SDK_OVERRIDE }}" | tr -d ' \t\r\n'` ; then
227             SDKROOT=`echo "${{ env.SDK_OVERRIDE }}" | tr -d ' \t\r\n'`
228             export SDKROOT
229           fi
230           ./bootstrap
231           CFLAGS=""
232           CXXFLAGS=""
233           OBJCXXFLAGS=""
234           LDFLAGS=""
235           DEPENDENCY_TRACKING=""
236           if test -n `echo "${{ env.UNIVERSAL_ARCHS }}" | tr -d ' \t\r\n'` ; then
237             DEPENDENCY_TRACKING="--disable-dependency-tracking --disable-pch"
238             # Include what configure normally infers for the compiler flags.
239             # Without -O2, the generated executables take painfully long to
240             # read the data files.
241             CFLAGS="$CFLAGS -g -O2"
242             CXXFLAGS="$CXXFLAGS -g -O2"
243             OBJCXXFLAGS="$OBJCXXFLAGS -g -O2"
244             for arch in ${{ env.UNIVERSAL_ARCHS }} ; do
245               option="-arch $arch"
246               CFLAGS="$CFLAGS $option"
247               CXXFLAGS="$CXXFLAGS $option"
248               OBJCXXFLAGS="$OBJCXXFLAGS $option"
249               LDFLAGS="$LDFLAGS $option"
250             done
251             echo "Performing a univeral build:"
252             echo "  CFLAGS = $CFLAGS"
253             echo "  CXXFLAGS = $CXXFLAGS"
254             echo "  OBJCXXFLAGS = $OBJCXXFLAGS"
255             echo "  LDFLAGS = $LDFLAGS"
256           fi
257           env CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" \
258             OBJCXXFLAGS="$OBJCXXFLAGS" LDFLAGS="$LDFLAGS" \
259             ./configure --enable-cocoa --disable-japanese $DEPENDENCY_TRACKING
260           make install
261           mkdir disttemp
262           mv "${{ steps.store_config.outputs.name }}".app disttemp
263           hdiutil create -quiet -volname "${{ steps.store_config.outputs.cap }}-${{ steps.store_config.outputs.version }}-English" -srcfolder disttemp disttemp.dmg
264           archive_prefix="${{ steps.store_config.outputs.cap }}-${{ steps.store_config.outputs.version }}-English"
265           echo "archive_file=${archive_prefix}.dmg" >> $GITHUB_OUTPUT
266           hdiutil convert disttemp.dmg -quiet -format UDZO -imagekey zlib-level=6 -o "${archive_prefix}.dmg"
267
268       - name: Create Artifact with Mac English Archive Path
269         run: |
270           echo archive_path= '${{ steps.create_mac_en_archive.outputs.archive_file }}' > $MAC_ENGLISH_ARTIFACT_PATH
271
272       - name: Upload Artifact with Mac English Archive Path
273         uses: actions/upload-artifact@v4
274         with:
275           name: ${{ env.MAC_ENGLISH_ARTIFACT }}
276           path: ${{ env.MAC_ENGLISH_ARTIFACT_PATH }}
277           retention-days: 1
278
279       - name: Upload Mac English Archive as Artifact
280         uses: actions/upload-artifact@v4
281         with:
282           name: ${{ env.MAC_ENGLISH_ARCHIVE_ARTIFACT }}
283           path: ${{ steps.create_mac_en_archive.outputs.archive_file }}
284           retention-days: 1
285
286   mac_ja:
287     needs: [setup]
288     name: Mac Japanese
289     runs-on: macos-latest
290     steps:
291       - name: Download Artifact with Configuration Information
292         uses: actions/download-artifact@v4
293         with:
294           name: ${{ env.CONFIG_ARTIFACT }}
295
296       - name: Extract Configuration Information and Store in Step Outputs
297         id: store_config
298         run: |
299           name=`sed -E -n -e 's/name= //p' $CONFIG_ARTIFACT_PATH`
300           echo "name=$name" >> $GITHUB_OUTPUT
301           cap=`sed -E -n -e 's/cap= //p' $CONFIG_ARTIFACT_PATH`
302           echo "cap=$cap" >> $GITHUB_OUTPUT
303           version=`sed -E -n -e 's/version= //p' $CONFIG_ARTIFACT_PATH`
304           echo "version=$version" >> $GITHUB_OUTPUT
305
306       - name: Clone Project
307         uses: actions/checkout@v4
308         with:
309           submodules: true
310
311       # Requires automake, autoconf, and nkf; install those via homebrew
312       # (available by default).
313       - name: Install Build Dependencies
314         run: |
315           brew install m4
316           brew install autoconf
317           brew install automake
318           brew install nkf
319
320       - name: Create Mac Japanese Archive
321         id: create_mac_ja_archive
322         run: |
323           if test -n `echo "${{ env.SDK_OVERRIDE }}" | tr -d ' \t\r\n'` ; then
324             SDKROOT=`echo "${{ env.SDK_OVERRIDE }}" | tr -d ' \t\r\n'`
325             export SDKROOT
326           fi
327           ./bootstrap
328           CFLAGS=""
329           CXXFLAGS=""
330           OBJCXXFLAGS=""
331           LDFLAGS=""
332           DEPENDENCY_TRACKING=""
333           if test -n `echo "${{ env.UNIVERSAL_ARCHS }}" | tr -d ' \t\r\n'` ; then
334             DEPENDENCY_TRACKING="--disable-dependency-tracking --disable-pch"
335             # Include what configure normally infers for the compiler flags.
336             # Without -O2, the generated executables take painfully long to
337             # read the data files.
338             CFLAGS="$CFLAGS -g -O2"
339             CXXFLAGS="$CXXFLAGS -g -O2"
340             OBJCXXFLAGS="$OBJCXXFLAGS -g -O2"
341             for arch in ${{ env.UNIVERSAL_ARCHS }} ; do
342               option="-arch $arch"
343               CFLAGS="$CFLAGS $option"
344               CXXFLAGS="$CXXFLAGS $option"
345               OBJCXXFLAGS="$OBJCXXFLAGS $option"
346               LDFLAGS="$LDFLAGS $option"
347             done
348             echo "Performing a univeral build:"
349             echo "  CFLAGS = $CFLAGS"
350             echo "  CXXFLAGS = $CXXFLAGS"
351             echo "  OBJCXXFLAGS = $OBJCXXFLAGS"
352             echo "  LDFLAGS = $LDFLAGS"
353           fi
354           env CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" \
355             OBJCXXFLAGS="$OBJCXXFLAGS" LDFLAGS="$LDFLAGS" \
356             ./configure --enable-cocoa $DEPENDENCY_TRACKING
357           make install
358           mkdir disttemp
359           mv "${{ steps.store_config.outputs.name }}".app disttemp
360           hdiutil create -quiet -volname "${{ steps.store_config.outputs.cap }}-${{ steps.store_config.outputs.version}}-Japanese" -srcfolder disttemp disttemp.dmg
361           archive_prefix="${{ steps.store_config.outputs.cap }}-${{ steps.store_config.outputs.version }}-Japanese"
362           echo "archive_file=${archive_prefix}.dmg" >> $GITHUB_OUTPUT
363           hdiutil convert disttemp.dmg -quiet -format UDZO -imagekey zlib-level=6 -o "${archive_prefix}.dmg"
364
365       - name: Create Artifact with Mac Japanese Archive Path
366         run: |
367           echo archive_path= '${{ steps.create_mac_ja_archive.outputs.archive_file }}' > $MAC_JAPANESE_ARTIFACT_PATH
368
369       - name: Upload Artifact with Mac Japanese Archive Path
370         uses: actions/upload-artifact@v4
371         with:
372           name: ${{ env.MAC_JAPANESE_ARTIFACT }}
373           path: ${{ env.MAC_JAPANESE_ARTIFACT_PATH }}
374           retention-days: 1
375
376       - name: Upload Mac Japanese Archive as Artifact
377         uses: actions/upload-artifact@v4
378         with:
379           name: ${{ env.MAC_JAPANESE_ARCHIVE_ARTIFACT }}
380           path: ${{ steps.create_mac_ja_archive.outputs.archive_file }}
381           retention-days: 1
382
383   release:
384     needs: [ setup, source, mac_en, mac_ja ]
385     name: Create GitHub Release
386     runs-on: ubuntu-latest
387     steps:
388       - name: Download Artifact with Configuration Information
389         uses: actions/download-artifact@v4
390         with:
391           name: ${{ env.CONFIG_ARTIFACT }}
392
393       - name: Extract Configuration Information and Store in Step Outputs
394         id: store_config
395         run: |
396           version=`sed -E -n -e 's/version= //p' $CONFIG_ARTIFACT_PATH`
397           echo "version=$version" >> $GITHUB_OUTPUT
398           tag=`sed -E -n -e 's/tag= //p' $CONFIG_ARTIFACT_PATH`
399           echo "tag=$tag" >> $GITHUB_OUTPUT
400           prerelease=`sed -E -n -e 's/prerelease= //p' $CONFIG_ARTIFACT_PATH`
401           echo "prerelease=$prerelease" >> $GITHUB_OUTPUT
402           draft=`sed -E -n -e 's/draft= //p' $CONFIG_ARTIFACT_PATH`
403           echo "draft=$draft" >> $GITHUB_OUTPUT
404
405       - name: Download Artifact with Source Archive Path
406         uses: actions/download-artifact@v4
407         with:
408           name: ${{ env.SRC_ARTIFACT }}
409
410       - name: Extract Source Archive Path and Store in Step Outputs
411         id: store_src
412         run: |
413           archive_path=`sed -E -n -e 's/archive_path= //p' $SRC_ARTIFACT_PATH`
414           echo "archive_path=$archive_path" >> $GITHUB_OUTPUT
415
416       - name: Download Artifact with Source Archive
417         uses: actions/download-artifact@v4
418         with:
419           name: ${{ env.SRC_ARCHIVE_ARTIFACT }}
420
421       - name: Download Artifact with Mac English Archive Path
422         uses: actions/download-artifact@v4
423         with:
424           name: ${{ env.MAC_ENGLISH_ARTIFACT }}
425
426       - name: Extract Mac English Archive Path and Store in Step Outputs
427         id: store_mac_en
428         run: |
429           archive_path=`sed -E -n -e 's/archive_path= //p' $MAC_ENGLISH_ARTIFACT_PATH`
430           echo "archive_path=$archive_path" >> $GITHUB_OUTPUT
431
432       - name: Download Artifact with Mac English Archive
433         uses: actions/download-artifact@v4
434         with:
435           name: ${{ env.MAC_ENGLISH_ARCHIVE_ARTIFACT }}
436
437       - name: Download Artifact with Mac Japanese Archive Path
438         uses: actions/download-artifact@v4
439         with:
440           name: ${{ env.MAC_JAPANESE_ARTIFACT }}
441
442       - name: Extract Mac Japanese Archive Path and Store in Step Outputs
443         id: store_mac_ja
444         run: |
445           archive_path=`sed -E -n -e 's/archive_path= //p' $MAC_JAPANESE_ARTIFACT_PATH`
446           echo "archive_path=$archive_path" >> $GITHUB_OUTPUT
447
448       - name: Download Artifact with Mac Japanese Archive
449         uses: actions/download-artifact@v4
450         with:
451           name: ${{ env.MAC_JAPANESE_ARCHIVE_ARTIFACT }}
452
453       - name: Populate Release
454         uses: softprops/action-gh-release@v1
455         with:
456           tag_name: "${{ steps.store_config.outputs.tag }}"
457           name: ${{ steps.store_config.outputs.version }}
458           target_commitish: ${{ github.sha }}
459           draft: ${{ steps.store_config.outputs.draft }}
460           prerelease: ${{ steps.store_config.outputs.prerelease }}
461           files: |
462             ${{ steps.store_src.outputs.archive_path }}
463             ${{ steps.store_mac_en.outputs.archive_path }}
464             ${{ steps.store_mac_ja.outputs.archive_path }}
465           token: ${{ secrets.GITHUB_TOKEN }}