summaryrefslogtreecommitdiff
path: root/.github/workflows/build.yml
diff options
context:
space:
mode:
Diffstat (limited to '.github/workflows/build.yml')
-rw-r--r--.github/workflows/build.yml130
1 files changed, 117 insertions, 13 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 946e7490..31c8d7f8 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -1,20 +1,124 @@
name: build
-on: push
+
+on:
+ push:
+ branches:
+ - master
+ tags:
+ - "*"
+ pull_request:
+ branches:
+ - master
+
+env:
+ PROJECT: lua-language-server
+ BIN_DIR: bin
+
jobs:
compile:
- runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
- os: [windows-latest, ubuntu-18.04, macos-latest]
+ include:
+ - { os: ubuntu-18.04, target: linux, platform: linux-x64 }
+ - { 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 }}
steps:
- - uses: actions/checkout@v1
- with:
- ref: refs/heads/master
- submodules : recursive
- - uses: actboy168/setup-luamake@master
- - run: luamake
- - uses: actions/upload-artifact@v1.0.0
- with:
- name: lua-language-server
- path: bin
+ - uses: actions/checkout@v2
+ 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 ::set-output name=PKG_VERSION::${PKG_VERSION}
+ echo ::set-output name=PKG_BASENAME::${PKG_BASENAME}
+ echo ::set-output name=PKG_NAME::${PKG_NAME}
+ echo ::set-output name=PKG_PATH::"${PKG_STAGING}/${PKG_NAME}"
+ echo ::set-output name=PKG_STAGING::${PKG_STAGING}
+
+ - uses: actions/upload-artifact@v2
+ with:
+ name: ${{ steps.vars.outputs.PKG_BASENAME }}
+ path: |
+ ${{ env.BIN_DIR }}
+ main.lua
+ debugger.lua
+ LICENSE
+ changelog.md
+ locale
+ 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}*"
+
+ echo ::set-output name=PKG_SUBMOD_PATH::${PKG_SUBMOD_PATH}
+
+ - 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 }}