Skip to content

Commit cb69107

Browse files
authored
Merge pull request #65 from uyjulian/ci_improvements_20251010
Apply changes from ps2toolchain-dvp 20251010
2 parents a57382c + e752745 commit cb69107

File tree

3 files changed

+145
-54
lines changed

3 files changed

+145
-54
lines changed

.github/workflows/compilation.yml

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ on:
1010
- '**.md'
1111
- '**.rst'
1212
repository_dispatch:
13-
types: [run_build, run_release]
13+
types:
14+
- run_build
15+
- run_release
1416
workflow_dispatch: {}
1517
env:
1618
HOMEBREW_NO_ANALYTICS: 1
@@ -31,7 +33,7 @@ jobs:
3133
container: null
3234
container-options: " "
3335
macos-package-manager: brew
34-
- runs-on: macos-13
36+
- runs-on: macos-15-intel
3537
architecture: x86_64
3638
shell: bash
3739
container: null
@@ -112,30 +114,9 @@ jobs:
112114
if test -f ./build-all.sh; then ./build-all.sh; fi
113115
if test -f ./toolchain.sh; then ./toolchain.sh; fi
114116
115-
- name: Print version of executables (ps2toolchain-iop)
116-
if: github.event.repository.name == 'ps2toolchain-iop'
117+
- name: Print version of executables
117118
run: |
118-
export PS2DEV=$PWD/ps2dev
119-
export PATH=$PATH:$PS2DEV/iop/bin
120-
mipsel-none-elf-as --version
121-
mipsel-none-elf-ld --version
122-
mipsel-none-elf-gcc --version
123-
124-
- name: Print version of executables (ps2toolchain-ee)
125-
if: github.event.repository.name == 'ps2toolchain-ee'
126-
run: |
127-
export PS2DEV=$PWD/ps2dev
128-
export PATH=$PATH:$PS2DEV/ee/bin
129-
mips64r5900el-ps2-elf-as --version
130-
mips64r5900el-ps2-elf-ld --version
131-
mips64r5900el-ps2-elf-gcc --version
132-
133-
- name: Print version of executables (ps2toolchain-dvp)
134-
if: github.event.repository.name == 'ps2toolchain-dvp'
135-
run: |
136-
export PS2DEV=$PWD/ps2dev
137-
export PATH=$PATH:$PS2DEV/dvp/bin
138-
dvp-as --version
119+
if test -f ./config/ci-print-version.sh; then ./config/ci-print-version.sh; fi
139120
140121
- name: Get short SHA
141122
id: slug

.github/workflows/docker.yml

Lines changed: 132 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,111 @@ on:
1212
- '**.rst'
1313
workflow_dispatch: {}
1414
repository_dispatch:
15-
types: [run_build]
15+
types:
16+
- run_build
1617

1718
jobs:
1819
build:
19-
env:
20-
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
21-
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
22-
BASE_DOCKER_IMAGE_NAME: ${{ (github.event.repository.name == 'ps2sdk' && 'ps2toolchain') || (github.event.repository.name == 'ps2sdk-ports' && 'ps2sdk') || (github.event.repository.name == 'ps2-packer' && 'ps2sdk') || (github.event.repository.name == 'ps2dev' && 'ps2sdk-ports') || 'none' }}
2320
strategy:
2421
matrix:
25-
runs-on: [ubuntu-latest, ubuntu-24.04-arm]
26-
runs-on: ${{ matrix.runs-on }}
22+
platform:
23+
- runs-on: ubuntu-latest
24+
container-platform: linux/amd64
25+
- runs-on: ubuntu-24.04-arm
26+
container-platform: linux/arm64
27+
runs-on: ${{ matrix.platform.runs-on }}
2728
timeout-minutes: 180
2829

2930
steps:
3031
- name: Checkout repository
3132
uses: actions/checkout@v4
3233

34+
- name: Prepare
35+
run: |
36+
platform=${{ matrix.platform.container-platform }}
37+
printf 'PLATFORM_PAIR=%s\n' "${platform//\//-}" >> $GITHUB_ENV
38+
39+
- name: Login to Github Container Registry
40+
uses: docker/login-action@v3
41+
with:
42+
registry: ghcr.io
43+
username: ${{ github.actor }}
44+
password: ${{ secrets.GITHUB_TOKEN }}
45+
46+
- name: Prepare additional environment variables from repo
47+
run: if test -f ./config/ci-docker-env.ini; then cat ./config/ci-docker-env.ini | sed -e 's/$REPOSITORY_OWNER/'"${{ github.repository_owner }}"'/g;s/$DOCKER_TAG/'"${{ env.DOCKER_TAG }}"'/g' >> $GITHUB_ENV; fi
48+
3349
- name: Extract DOCKER_TAG using tag name
34-
if: startsWith(github.ref, 'refs/tags/')
50+
if: env.BUILD_ARGS_LIST != null
3551
run: |
36-
printf 'DOCKER_TAG=%s\n' "${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
52+
printf 'BUILD_ARGS_LIST_NEWLINES<<EOF\n%s\nEOF\n' "${{ env.BUILD_ARGS_LIST }}" | tr ' ' $'\n' >> $GITHUB_ENV
3753
38-
- name: Use default DOCKER_TAG
39-
if: startsWith(github.ref, 'refs/tags/') != true
54+
- name: Docker meta
55+
id: meta
56+
uses: docker/metadata-action@v5
57+
with:
58+
images: ghcr.io/${{ github.repository }}
59+
60+
- name: Set up Docker Buildx
61+
uses: docker/setup-buildx-action@v3
62+
63+
- name: Build and Push to container registry
64+
id: build
65+
uses: docker/build-push-action@v6
66+
with:
67+
platforms: ${{ matrix.platform.container-platform }}
68+
labels: ${{ steps.meta.outputs.labels }}
69+
tags: ghcr.io/${{ github.repository }}
70+
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
71+
build-args: ${{ env.BUILD_ARGS_LIST_NEWLINES }}
72+
73+
- name: Export digest
74+
run: |
75+
mkdir -p ${{ runner.temp }}/digests
76+
digest="${{ steps.build.outputs.digest }}"
77+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
78+
79+
- name: Upload digest
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: digests-${{ env.PLATFORM_PAIR }}
83+
path: ${{ runner.temp }}/digests/*
84+
if-no-files-found: error
85+
retention-days: 1
86+
87+
merge:
88+
needs:
89+
- build
90+
runs-on: ubuntu-latest
91+
timeout-minutes: 20
92+
env:
93+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
94+
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
95+
outputs:
96+
dest-repo: ${{ steps.dest-repo.outputs.DEST_REPO }}
97+
98+
steps:
99+
- name: Checkout repository
100+
uses: actions/checkout@v4
101+
102+
- name: Install Ubuntu packages
40103
run: |
41-
echo "DOCKER_TAG=latest" >> $GITHUB_ENV
104+
sudo apt-get -y update
105+
sudo apt-get -y -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' install jq
106+
107+
- name: Download digests
108+
uses: actions/download-artifact@v4
109+
with:
110+
path: ${{ runner.temp }}/digests
111+
pattern: digests-*
112+
merge-multiple: true
42113

43114
- name: Login to DockerHub
44115
uses: docker/login-action@v3
45116
if: env.DOCKER_USERNAME != null
46117
with:
47-
username: ${{ secrets.DOCKER_USERNAME }}
48-
password: ${{ secrets.DOCKER_PASSWORD }}
118+
username: ${{ env.DOCKER_USERNAME }}
119+
password: ${{ env.DOCKER_PASSWORD }}
49120

50121
- name: Login to Github Container Registry
51122
uses: docker/login-action@v3
@@ -54,33 +125,53 @@ jobs:
54125
username: ${{ github.actor }}
55126
password: ${{ secrets.GITHUB_TOKEN }}
56127

128+
- name: Extract DOCKER_TAG using tag name
129+
if: startsWith(github.ref, 'refs/tags/')
130+
run: |
131+
printf 'DOCKER_TAG=%s\n' "${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
132+
133+
- name: Use default DOCKER_TAG
134+
if: startsWith(github.ref, 'refs/tags/') != true
135+
run: |
136+
printf 'DOCKER_TAG=%s\n' "latest" >> $GITHUB_ENV
137+
57138
- name: Set docker tag list to include DockerHub if credentials available
58139
if: env.DOCKER_USERNAME != null
59140
run: |
60-
printf 'DOCKER_TAG_LIST=%s\n' "ghcr.io/${{ github.repository }}:${{ env.DOCKER_TAG }},${{ github.repository }}:${{ env.DOCKER_TAG }}" >> $GITHUB_ENV
141+
printf 'DOCKER_CONTAINER_LIST<<EOF\n%s\nEOF\n' "ghcr.io/${{ github.repository }}"$'\n'"${{ github.repository }}" >> $GITHUB_ENV
61142
62143
- name: Set docker tag list to not include DockerHub if credentials not available
63144
if: env.DOCKER_USERNAME == null
64145
run: |
65-
printf 'DOCKER_TAG_LIST=%s\n' "ghcr.io/${{ github.repository }}:${{ env.DOCKER_TAG }}" >> $GITHUB_ENV
146+
printf 'DOCKER_CONTAINER_LIST<<EOF\n%s\nEOF\n' "ghcr.io/${{ github.repository }}" >> $GITHUB_ENV
66147
67-
- name: Build and Push to container registry
68-
uses: docker/build-push-action@v5
148+
- name: Docker meta
149+
id: meta
150+
uses: docker/metadata-action@v5
69151
with:
70-
push: true
71-
tags: ${{ env.DOCKER_TAG_LIST }}
72-
build-args: |
73-
BASE_DOCKER_IMAGE=ghcr.io/${{ github.repository_owner }}/${{ env.BASE_DOCKER_IMAGE_NAME }}:${{ env.DOCKER_TAG }}
74-
BASE_DOCKER_DVP_IMAGE=ghcr.io/${{ github.repository_owner }}/ps2toolchain-dvp:${{ env.DOCKER_TAG }}
75-
BASE_DOCKER_IOP_IMAGE=ghcr.io/${{ github.repository_owner }}/ps2toolchain-iop:${{ env.DOCKER_TAG }}
76-
BASE_DOCKER_EE_IMAGE=ghcr.io/${{ github.repository_owner }}/ps2toolchain-ee:${{ env.DOCKER_TAG }}
152+
images: ${{ env.DOCKER_CONTAINER_LIST }}
153+
tags: |
154+
type=raw,value=${{ env.DOCKER_TAG }}
155+
156+
- name: Set up Docker Buildx
157+
uses: docker/setup-buildx-action@v3
158+
159+
- name: Create manifest list and push
160+
working-directory: ${{ runner.temp }}/digests
161+
run: |
162+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") $(printf 'ghcr.io/${{ github.repository }}@sha256:%s ' *)
163+
164+
- name: Inspect image
165+
run: |
166+
docker buildx imagetools inspect ghcr.io/${{ github.repository }}:${{ steps.meta.outputs.version }}
77167
78168
- name: Gather information for repository dispatch
79169
id: dest-repo
80170
run: if test -f ./config/repository-dispatch.ini; then cat ./config/repository-dispatch.ini >> $GITHUB_OUTPUT; fi
81171

82172
perform-repository-dispatch:
83-
needs: [build]
173+
needs:
174+
- merge
84175
runs-on: ubuntu-latest
85176
container:
86177
image: ubuntu:20.04
@@ -90,9 +181,21 @@ jobs:
90181
DISPATCH_TOKEN: ${{ secrets.DISPATCH_TOKEN }}
91182
strategy:
92183
matrix:
93-
dest-repo: ${{ fromJson(needs.build.outputs.DEST_REPO) }}
184+
dest-repo: ${{ fromJson(needs.merge.outputs.dest-repo) }}
94185

95186
steps:
187+
- name: Gather environment variables (normal)
188+
if: github.event_name != 'repository_dispatch'
189+
run: |
190+
printf 'PAYLOAD_REPO_PARENT_NAME=%s\n' "${{ github.repository }}" >> $GITHUB_ENV
191+
printf 'PAYLOAD_REPO_PARENT_SHA=%s\n' "${{ github.sha }}" >> $GITHUB_ENV
192+
193+
- name: Gather environment variables (dispatch)
194+
if: github.event_name == 'repository_dispatch'
195+
run: |
196+
printf 'PAYLOAD_REPO_PARENT_NAME=%s\n' "${{ github.event.client_payload.parent_name }}" >> $GITHUB_ENV
197+
printf 'PAYLOAD_REPO_PARENT_SHA=%s\n' "${{ github.event.client_payload.parent_sha }}" >> $GITHUB_ENV
198+
96199
- name: Send Compile action
97200
run: |
98201
export DISPATCH_ACTION="$(printf 'run_build\n')"
@@ -105,7 +208,7 @@ jobs:
105208
repository: ${{ github.repository_owner }}/${{ matrix.dest-repo }}
106209
token: ${{ secrets.DISPATCH_TOKEN }}
107210
event-type: ${{ env.NEW_DISPATCH_ACTION }}
108-
client-payload: '{"ref": "${{ github.ref }}"}'
211+
client-payload: '{"ref": "${{ github.ref }}", "parent_name": "${{ env.PAYLOAD_REPO_PARENT_NAME }}", "parent_sha": "${{ env.PAYLOAD_REPO_PARENT_SHA }}"}'
109212

110213
- name: Repository Dispatch to specific ${{ matrix.dest-repo }}
111214
uses: peter-evans/repository-dispatch@v3
@@ -114,4 +217,4 @@ jobs:
114217
repository: ${{ matrix.dest-repo }}
115218
token: ${{ secrets.DISPATCH_TOKEN }}
116219
event-type: ${{ env.NEW_DISPATCH_ACTION }}
117-
client-payload: '{"ref": "${{ github.ref }}"}'
220+
client-payload: '{"ref": "${{ github.ref }}", "parent_name": "${{ env.PAYLOAD_REPO_PARENT_NAME }}", "parent_sha": "${{ env.PAYLOAD_REPO_PARENT_SHA }}"}'

config/ci-print-version.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
export PS2DEV=$PWD/ps2dev
4+
export PATH=$PATH:$PS2DEV/ee/bin
5+
mips64r5900el-ps2-elf-as --version
6+
mips64r5900el-ps2-elf-ld --version
7+
mips64r5900el-ps2-elf-gcc --version

0 commit comments

Comments
 (0)