forked from MUME/MMapper
-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (92 loc) · 3.15 KB
/
Copy pathbuild-wasm.yml
File metadata and controls
107 lines (92 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: build-wasm
on:
push:
tags:
- 'v*'
- 'beta'
branches:
- master
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
permissions:
contents: read
packages: write
jobs:
build-wasm:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
fetch-depth: 0
submodules: true
- name: Set Git info
id: info
run: |
RAW_TAG="${{ github.ref_name }}"
# Explicitly initialize outputs to avoid brittle logic
PUSH_LATEST="false"
IS_TAG="false"
if [[ "${{ github.ref_type }}" == "tag" ]]; then
IS_TAG="true"
VERSION=$RAW_TAG
VERSION_CLEAN=$(echo $VERSION | sed 's/^v//')
if [[ "$RAW_TAG" != "beta" ]]; then
PUSH_LATEST="true"
fi
else
VERSION=${{ github.sha }}
VERSION_CLEAN=${VERSION:0:7}
fi
echo "VERSION=${VERSION_CLEAN}" >> $GITHUB_OUTPUT
echo "RAW_TAG=${VERSION}" >> $GITHUB_OUTPUT
echo "IS_TAG=${IS_TAG}" >> $GITHUB_OUTPUT
echo "PUSH_LATEST=${PUSH_LATEST}" >> $GITHUB_OUTPUT
echo "FILE=mmapper-${VERSION_CLEAN}-wasm.zip" >> $GITHUB_OUTPUT
echo "REPO_LC=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to GitHub Container Registry
if: steps.info.outputs.IS_TAG == 'true'
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Load Image
uses: docker/build-push-action@v7
with:
context: .
load: true
build-args: |
JOBS=1
tags: local-wasm-build:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Extract Artifacts from Image
run: |
docker create --name extract local-wasm-build:latest
mkdir -p demo
docker cp extract:/usr/share/nginx/html/. ./demo/
docker rm extract
zip -r ${{ steps.info.outputs.FILE }} demo
- name: Upload Zip Package
uses: actions/upload-artifact@v7
with:
name: mmapper-${{ steps.info.outputs.VERSION }}-wasm
path: ${{ steps.info.outputs.FILE }}
- name: Finalize Image Push to GHCR
if: steps.info.outputs.IS_TAG == 'true'
run: |
# Instead of rebuilding, we just tag the local image and push it
IMAGE_BASE="ghcr.io/${{ steps.info.outputs.REPO_LC }}"
TAG_VERSION="$IMAGE_BASE:${{ steps.info.outputs.RAW_TAG }}"
docker tag local-wasm-build:latest "$TAG_VERSION"
docker push "$TAG_VERSION"
if [[ "${{ steps.info.outputs.PUSH_LATEST }}" == "true" ]]; then
docker tag local-wasm-build:latest "$IMAGE_BASE:latest"
docker push "$IMAGE_BASE:latest"
fi