-
-
Notifications
You must be signed in to change notification settings - Fork 325
144 lines (124 loc) · 4.71 KB
/
build.yml
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: build
on:
push:
branches:
- master
tags:
- "*"
pull_request:
branches:
- master
env:
PROJECT: lua-language-server
BIN_DIR: bin
jobs:
compile:
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-20.04, target: linux, platform: linux-x64, container: 'ubuntu:18.04' }
- { os: ubuntu-20.04, target: linux, platform: linux-arm64, container: 'ubuntu:18.04' }
- { os: macos-11, target: darwin, platform: darwin-x64 }
- { os: macos-11, target: darwin, platform: darwin-arm64 }
- { os: windows-latest, target: windows, platform: win32-ia32 }
- { os: windows-latest, target: windows, platform: win32-x64 }
runs-on: ${{ matrix.os }}
container:
image: ${{ matrix.container }}
steps:
- name: Prepare container
if: ${{ matrix.target == 'linux' }}
run: |
apt-get update
apt-get install -y software-properties-common
add-apt-repository -y ppa:ubuntu-toolchain-r/test # For gcc-9 and g++-9
add-apt-repository -y ppa:git-core/ppa # For git>=2.18.
apt-get update
apt-get install -y sudo git gcc-9 g++-9
- name: Install aarch64-linux-gnu
if: ${{ matrix.platform == 'linux-arm64' }}
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: actboy168/setup-luamake@master
- run: luamake -platform ${{ matrix.platform }}
- name: Setting up workflow variables
id: vars
shell: bash
run: |
# Package version
if [[ $GITHUB_REF = refs/tags/* ]]; then
PKG_VERSION=${GITHUB_REF##*/}
else
PKG_VERSION=${GITHUB_SHA:0:7}
fi
# Package suffix relative to the platform
if [[ "${{ matrix.target }}" = windows ]]; then
PKG_SUFFIX="zip"
else
PKG_SUFFIX="tar.gz"
fi
# Package name w/ version
PKG_BASENAME="${{ env.PROJECT }}-${PKG_VERSION}-${{ matrix.platform }}"
# Full name of the tarball asset
PKG_NAME="${PKG_BASENAME}.${PKG_SUFFIX}"
# Staging area for tarballs
PKG_STAGING="ci_staging/$PKG_BASENAME"
echo PKG_VERSION=${PKG_VERSION} >> $GITHUB_OUTPUT
echo PKG_BASENAME=${PKG_BASENAME} >> $GITHUB_OUTPUT
echo PKG_NAME=${PKG_NAME} >> $GITHUB_OUTPUT
echo PKG_PATH="${PKG_STAGING}/${PKG_NAME}" >> $GITHUB_OUTPUT
echo PKG_STAGING=${PKG_STAGING} >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v3
with:
name: ${{ steps.vars.outputs.PKG_BASENAME }}
path: |
${{ env.BIN_DIR }}
main.lua
debugger.lua
LICENSE
changelog.md
locale
doc
meta
script
- name: Package tarballs
if: startsWith(github.ref, 'refs/tags/')
shell: bash
run: |
STAGING=${{ steps.vars.outputs.PKG_STAGING }}
NAME=${{ steps.vars.outputs.PKG_NAME }}
# Making the staging area
mkdir -p ${STAGING}
# Copying binary and runtime files to staging area
cp -r main.lua debugger.lua LICENSE changelog.md locale meta script ${{ env.BIN_DIR }} ${STAGING}
# Creating release assets
pushd "${STAGING}/" >/dev/null
if [[ "${{ matrix.target }}" = windows ]]; then
7z -y a ${NAME} * | tail -2
else
tar czf ${NAME} *
fi
popd >/dev/null
# Packaging submodules for homebrew distribution
- name: Package submodules
id: submodules
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.platform == 'darwin-x64' }}
run: |
STAGING=${{ steps.vars.outputs.PKG_STAGING }}
PKG_SUBMOD_NAME="${{ env.PROJECT }}-${{ steps.vars.outputs.PKG_VERSION }}-submodules.zip"
PKG_SUBMOD_PATH="${STAGING}/$PKG_SUBMOD_NAME"
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*"
echo PKG_SUBMOD_PATH=${PKG_SUBMOD_PATH} >> $GITHUB_OUTPUT
- name: Publish release assets
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
generate_release_notes: true
files: |
${{ steps.vars.outputs.PKG_PATH }}
${{ steps.submodules.outputs.PKG_SUBMOD_PATH }}