Skip to content

Commit 3e6fd3c

Browse files
committed
算了
1 parent a521892 commit 3e6fd3c

File tree

2 files changed

+105
-178
lines changed

2 files changed

+105
-178
lines changed

.github/workflows/build.yml

Lines changed: 105 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
push:
88
branches:
99
- master
10+
tags:
11+
- "*"
1012
pull_request:
1113
branches:
1214
- master
@@ -21,35 +23,71 @@ jobs:
2123
fail-fast: false
2224
matrix:
2325
include:
24-
- { os: ubuntu-20.04, target: linux, platform: linux-x64 }
25-
- { os: ubuntu-20.04, target: linux, platform: linux-arm64 }
26+
- { os: ubuntu-22.04, target: linux, platform: linux-x64, container: 'alpine:latest', libc: musl }
27+
- { os: ubuntu-20.04, target: linux, platform: linux-x64, container: 'ubuntu:18.04' }
28+
- { os: ubuntu-20.04, target: linux, platform: linux-arm64, container: 'ubuntu:18.04' }
2629
- { os: macos-11, target: darwin, platform: darwin-x64 }
2730
- { os: macos-11, target: darwin, platform: darwin-arm64 }
2831
- { os: windows-latest, target: windows, platform: win32-ia32 }
2932
- { os: windows-latest, target: windows, platform: win32-x64 }
3033
runs-on: ${{ matrix.os }}
34+
container:
35+
image: ${{ matrix.container }}
3136
steps:
32-
- uses: actions/checkout@v3
33-
with:
34-
submodules: recursive
37+
- name: Prepare container
38+
if: ${{ matrix.target == 'linux' && matrix.libc != 'musl' }}
39+
run: |
40+
apt-get update
41+
apt-get install -y software-properties-common
42+
add-apt-repository -y ppa:ubuntu-toolchain-r/test # For gcc-9 and g++-9
43+
add-apt-repository -y ppa:git-core/ppa # For git>=2.18.
44+
apt-get update
45+
apt-get install -y sudo git gcc-9 g++-9
3546
36-
- name: Prepare Linux-ARM64
37-
if: ${{ matrix.platform == 'linux-arm64' }}
47+
- name: Install aarch64-linux-gnu
48+
if: ${{ matrix.platform == 'linux-arm64' && matrix.libc != 'musl' }}
3849
run: |
50+
apt-get update
3951
apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
4052
41-
- name: Install Luamake
53+
- name: Prepare container env
54+
if: ${{ matrix.target == 'linux' && matrix.libc != 'musl' }}
55+
run: |
56+
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 100
57+
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 100
58+
59+
- name: Prepare container for musl
60+
if: ${{ matrix.target == 'linux' && matrix.libc == 'musl' }}
61+
run: |
62+
apk update
63+
apk add git ninja bash build-base nodejs linux-headers
64+
65+
- uses: actions/checkout@v3
66+
with:
67+
submodules: recursive
68+
69+
- name: Build for others step-1
70+
if: ${{ matrix.libc != 'musl' }}
4271
uses: actboy168/setup-luamake@master
4372

44-
- name: Luamake
73+
- name: Build for others step-2
74+
if: ${{ matrix.libc != 'musl' }}
4575
run: luamake -platform ${{ matrix.platform }}
4676

77+
- name: Build for musl
78+
if: ${{ matrix.target == 'linux' && matrix.libc == 'musl' }}
79+
run: ./make.sh
80+
4781
- name: Setting up workflow variables
4882
id: vars
4983
shell: bash
5084
run: |
5185
# Package version
52-
PKG_VERSION=${GITHUB_SHA:0:7}
86+
if [[ $GITHUB_REF = refs/tags/* ]]; then
87+
PKG_VERSION=${GITHUB_REF##*/}
88+
else
89+
PKG_VERSION=${GITHUB_SHA:0:7}
90+
fi
5391
5492
# Package suffix relative to the platform
5593
if [[ "${{ matrix.target }}" = windows ]]; then
@@ -60,8 +98,21 @@ jobs:
6098
6199
# Package name w/ version
62100
PKG_BASENAME="${{ env.PROJECT }}-${PKG_VERSION}-${{ matrix.platform }}"
101+
if [[ "${{ matrix.libc }}" = musl ]]; then
102+
PKG_BASENAME="${PKG_BASENAME}-${{matrix.libc}}"
103+
fi
104+
105+
# Full name of the tarball asset
106+
PKG_NAME="${PKG_BASENAME}.${PKG_SUFFIX}"
63107
108+
# Staging area for tarballs
109+
PKG_STAGING="ci_staging/$PKG_BASENAME"
110+
111+
echo PKG_VERSION=${PKG_VERSION} >> $GITHUB_OUTPUT
64112
echo PKG_BASENAME=${PKG_BASENAME} >> $GITHUB_OUTPUT
113+
echo PKG_NAME=${PKG_NAME} >> $GITHUB_OUTPUT
114+
echo PKG_PATH="${PKG_STAGING}/${PKG_NAME}" >> $GITHUB_OUTPUT
115+
echo PKG_STAGING=${PKG_STAGING} >> $GITHUB_OUTPUT
65116
66117
- uses: actions/upload-artifact@v3
67118
with:
@@ -76,3 +127,47 @@ jobs:
76127
doc
77128
meta
78129
script
130+
131+
- name: Package tarballs
132+
if: startsWith(github.ref, 'refs/tags/')
133+
shell: bash
134+
run: |
135+
STAGING=${{ steps.vars.outputs.PKG_STAGING }}
136+
NAME=${{ steps.vars.outputs.PKG_NAME }}
137+
138+
# Making the staging area
139+
mkdir -p ${STAGING}
140+
141+
# Copying binary and runtime files to staging area
142+
cp -r main.lua debugger.lua LICENSE changelog.md locale meta script ${{ env.BIN_DIR }} ${STAGING}
143+
144+
# Creating release assets
145+
pushd "${STAGING}/" >/dev/null
146+
if [[ "${{ matrix.target }}" = windows ]]; then
147+
7z -y a ${NAME} * | tail -2
148+
else
149+
tar czf ${NAME} *
150+
fi
151+
popd >/dev/null
152+
153+
# Packaging submodules for homebrew distribution
154+
- name: Package submodules
155+
id: submodules
156+
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.platform == 'darwin-x64' }}
157+
run: |
158+
STAGING=${{ steps.vars.outputs.PKG_STAGING }}
159+
PKG_SUBMOD_NAME="${{ env.PROJECT }}-${{ steps.vars.outputs.PKG_VERSION }}-submodules.zip"
160+
PKG_SUBMOD_PATH="${STAGING}/$PKG_SUBMOD_NAME"
161+
162+
zip -r $PKG_SUBMOD_PATH ./ -x "*.git*" -x "*.vscode*" -x "build*" -x "${{ env.BIN_DIR }}*" -x "${STAGING}*" -x "3rd/json.lua*" -x "log*" -x "ci_staging*"
163+
164+
echo PKG_SUBMOD_PATH=${PKG_SUBMOD_PATH} >> $GITHUB_OUTPUT
165+
166+
- name: Publish release assets
167+
uses: softprops/action-gh-release@v1
168+
if: startsWith(github.ref, 'refs/tags/')
169+
with:
170+
generate_release_notes: true
171+
files: |
172+
${{ steps.vars.outputs.PKG_PATH }}
173+
${{ steps.submodules.outputs.PKG_SUBMOD_PATH }}

.github/workflows/release.yml

Lines changed: 0 additions & 168 deletions
This file was deleted.

0 commit comments

Comments
 (0)