Skip to content

Commit 3d2bf1e

Browse files
committed
Refactor build of individual packages to reusable workflow
1 parent 1eefe17 commit 3d2bf1e

File tree

8 files changed

+204
-333
lines changed

8 files changed

+204
-333
lines changed

.github/scripts/build-package.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
set -e # exit on error
4+
set -x # echo on
5+
set -o pipefail # fail of any command in pipeline is an error
6+
7+
PACKAGE_REPOSITORY=$1
8+
9+
ARGUMENTS="--syncdeps \
10+
--rmdeps \
11+
--cleanbuild \
12+
--noconfirm \
13+
--noprogressbar \
14+
--nocheck \
15+
--force"
16+
17+
if [[ "$PACKAGE_REPOSITORY" == *MINGW* ]]; then
18+
MINGW_ARCH=mingw64 makepkg-mingw $ARGUMENTS --skippgpcheck
19+
else
20+
makepkg $ARGUMENTS
21+
fi
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set -e # exit on error
4+
set -x # echo on
5+
set -o pipefail # fail of any command in pipeline is an error
6+
7+
RUN_ID=$1
8+
NEEDS=`echo "$2" | /mingw64/bin/jq 'keys|join(" ")' | sed 's/"//g'`
9+
10+
for NEED in $NEEDS; do
11+
echo "Downloading $NEED artifact."
12+
/mingw64/bin/gh run download $RUN_ID -n $NEED
13+
done
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
set -e # exit on error
4+
set -x # echo on
5+
set -o pipefail # fail of any command in pipeline is an error
6+
7+
pacman -U --noconfirm *.pkg.tar.zst
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
set -e # exit on error
4+
set -x # echo on
5+
set -o pipefail # fail of any command in pipeline is an error
6+
7+
cp /opt/x86_64-w64-mingw32/include/pthread_signal.h /opt/aarch64-w64-mingw32/include/
8+
cp /opt/x86_64-w64-mingw32/include/pthread_unistd.h /opt/aarch64-w64-mingw32/include/
9+
cp /opt/x86_64-w64-mingw32/include/pthread_time.h /opt/aarch64-w64-mingw32/include/
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -e # exit on error
44
set -x # echo on
55
set -o pipefail # fail of any command in pipeline is an error
66

7-
pacman -Syu --noconfirm
7+
pacman -Syuu --noconfirm
88

99
# Add WoArm64 custom repository.
1010
REPO='[woarm64]
@@ -15,4 +15,3 @@ SigLevel = Optional
1515
echo -e "$REPO$(cat /etc/pacman.conf)" > /etc/pacman.conf
1616

1717
pacman -Sy --noconfirm
18-
pacman -S mingw-w64-cross-gcc --noconfirm
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Build MSYS2 package
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
package_name:
7+
description: "Package name to build"
8+
type: string
9+
needs:
10+
description: "Parent workflow job dependencies"
11+
type: string
12+
dependencies:
13+
description: "Install additional dependencies"
14+
type: string
15+
default: ""
16+
packages_repository:
17+
description: "MSYS2 packages repository to build from"
18+
type: string
19+
default: "Windows-on-ARM-Experiments/MSYS2-packages"
20+
packages_branch:
21+
description: "MSYS2 packages branch to build from"
22+
type: string
23+
default: "woarm64"
24+
25+
defaults:
26+
run:
27+
shell: msys2 {0}
28+
29+
env:
30+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
32+
jobs:
33+
build:
34+
runs-on: windows-latest
35+
36+
steps:
37+
- uses: msys2/setup-msys2@v2
38+
with:
39+
msystem: MSYS
40+
update: true
41+
42+
- name: Checkout repository
43+
uses: actions/checkout@v4
44+
45+
- name: Setup packages repository
46+
run: |
47+
`cygpath "${{ github.workspace }}"`/.github/scripts/setup-repository.sh
48+
49+
- name: Install dependencies
50+
run: |
51+
pacman -S --noconfirm \
52+
base-devel \
53+
git \
54+
mingw-w64-x86_64-github-cli \
55+
mingw-w64-x86_64-jq \
56+
${{ inputs.dependencies }}
57+
58+
- name: Checkout repository
59+
uses: actions/checkout@v4
60+
61+
- name: Checkout ${{ inputs.packages_repository }} repository
62+
uses: actions/checkout@v4
63+
with:
64+
repository: ${{ inputs.packages_repository }}
65+
ref: ${{ inputs.packages_branch }}
66+
path: ${{ github.workspace }}/packages
67+
68+
- name: Download artifacts
69+
if: ${{ inputs.needs }}
70+
run: |
71+
`cygpath "${{ github.workspace }}"`/.github/scripts/download-artifacts.sh ${{ github.run_id }} '${{ inputs.needs }}'
72+
73+
- name: Install artifacts
74+
if: ${{ inputs.needs }}
75+
run: |
76+
`cygpath "${{ github.workspace }}"`/.github/scripts/install-artifacts.sh
77+
78+
- name: Copy missing headers for mingw-w64-cross-crt
79+
if: ${{ inputs.package_name == 'mingw-w64-cross-crt' }}
80+
run: |
81+
`cygpath "${{ github.workspace }}"`/.github/scripts/pthread-headers-hack.sh
82+
83+
- name: Build ${{ inputs.package_name }}
84+
working-directory: ${{ github.workspace }}/packages/${{ inputs.package_name }}
85+
run: |
86+
`cygpath "${{ github.workspace }}"`/.github/scripts/build-package.sh ${{ inputs.packages_repository }}
87+
88+
- name: Upload ${{ inputs.package_name }}
89+
uses: actions/upload-artifact@v4
90+
with:
91+
name: ${{ inputs.package_name }}
92+
retention-days: 1
93+
path: ${{ github.workspace }}/packages/${{ inputs.package_name }}/*.pkg.tar.zst

.github/workflows/check-repository.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ on:
77
jobs:
88
build:
99
runs-on: windows-latest
10+
11+
defaults:
12+
run:
13+
shell: msys2 {0}
14+
1015
steps:
1116
- uses: msys2/setup-msys2@v2
1217
with:
@@ -16,13 +21,15 @@ jobs:
1621
- name: Checkout repository
1722
uses: actions/checkout@v4
1823

24+
- name: Setup packages repository
25+
run: |
26+
`cygpath "${{ github.workspace }}"`/.github/scripts/setup-repository.sh
27+
1928
- name: Install toolchain
20-
shell: msys2 {0}
2129
run: |
22-
`cygpath "${{ github.workspace }}"`/.github/scripts/install-toolchain.sh
30+
pacman -S mingw-w64-cross-gcc --noconfirm
2331
2432
- name: Build hello-world.exe
25-
shell: msys2 {0}
2633
run: |
2734
`cygpath "${{ github.workspace }}"`/.github/scripts/build-hello-world.sh
2835

0 commit comments

Comments
 (0)