aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/build.yml
blob: 9b124877770d35d05713b743390d920db706d1c5 (plain)
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
name: CI
on: { push: { branches: [master] } }
jobs:
  build_linux_android_windows:
    runs-on: ubuntu-latest
    defaults: { run: { shell: bash } }
    steps:
      - name: Checkout Code
        uses: actions/checkout@v3
        with: { fetch-depth: 0 }
      - name: Set Environment Variables
        run: |
          git config --global user.name "Github Actions" && git config --global user.email "adamdharrison@gmail.com"
          echo VERSION=`git describe --tags --abbrev=0 --match "v*" | tail -c +2` >> $GITHUB_ENV && echo FULL_VERSION=`git describe --tags --match "v*" | tail -c +2` >> $GITHUB_ENV && echo REV=$((`git describe --tags  --match "v*" | sed 's/.*-\([0-9]*\)-.*/\1/' | sed s/^v.*//` + 1)) >> $GITHUB_ENV
      - name: Clone Submodules
        run: git submodule update --init --depth=1
      - name: Build Linux
        run: |
          sudo apt-get install musl-tools musl musl-dev
          CC=musl-gcc ./build.sh -DLPM_STATIC -DLPM_VERSION='"'$FULL_VERSION-x86_64-linux'"' -static && tar -czvf lpm-$FULL_VERSION-x86_64-linux.tar.gz lpm
          cp lpm lpm.x86_64-linux
      - name: Build Android
        env: { ANDROID_ABI_VERSION: "26" }
        run: |
          export CMAKE_DEFAULT_FLAGS="-DCMAKE_ANDROID_NDK=$ANDROID_NDK_HOME -DCMAKE_ANDROID_API=$ANDROID_ABI_VERSION -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=NEVER -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_INCLUDE_PATH=$ANDROID_SYSROOT_NDK/sysroot/usr/include"
          export AR="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar"
          ./build.sh clean && export ARCH="arm-android" &&     BIN=lpm.$ARCH CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi$ANDROID_ABI_VERSION-clang   CFLAGS="-Dinline=" ./build.sh -DLPM_VERSION='"'$FULL_VERSION-$ARCH'"' -DLPM_STATIC
          ./build.sh clean && export ARCH="aarch64-android" && BIN=lpm.$ARCH CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android$ANDROID_ABI_VERSION-clang      CFLAGS="-Dinline=" ./build.sh -DLPM_VERSION='"'$FULL_VERSION-$ARCH'"' -DLPM_STATIC
          ./build.sh clean && export ARCH="x86-android" &&     BIN=lpm.$ARCH CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android$ANDROID_ABI_VERSION-clang         CFLAGS="-Dinline=" ./build.sh -DLPM_VERSION='"'$FULL_VERSION-$ARCH'"' -DLPM_STATIC
          ./build.sh clean && export ARCH="x86_64-android" &&  BIN=lpm.$ARCH CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android$ANDROID_ABI_VERSION-clang       CFLAGS="-Dinline=" ./build.sh -DLPM_VERSION='"'$FULL_VERSION-$ARCH'"' -DLPM_STATIC
      - name: Run Tests
        run: |
          ./lpm test t/run.lua
      # - name: Package Debian/Ubuntu
      #   env: { ARCH: "amd64", DESCRIPTION: "A plugin manager for the lite-xl text editor.", MAINTAINER: "Adam Harrison <adamdharrison@gmail.com>" }
      #   run: |
      #     export NAME=lpm_$VERSION.0-$REV""_$ARCH
      #     mkdir -p $NAME/usr/bin $NAME/DEBIAN && cp lpm $NAME/usr/bin
      #     printf "Package: lpm\nVersion: $VERSION\nArchitecture: $ARCH\nMaintainer: $MAINTAINER\nDescription: $DESCRIPTION\n" > $NAME/DEBIAN/control
      #     dpkg-deb --build --root-owner-group $NAME
      - name: Build Windows
        run: |
          sudo apt-get install mingw-w64 && ./build.sh clean && CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-gcc-ar WINDRES=x86_64-w64-mingw32-windres CMAKE_DEFAULT_FLAGS="-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=NEVER -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_INCLUDE_PATH=/usr/share/mingw-w64/include" LZMA_CONFIGURE="--host=x86_64-w64-mingw32" GIT2_CONFIGURE="-DDLLTOOL=x86_64-w64-mingw32-dlltool" ./build.sh -DLPM_STATIC -DLPM_VERSION='"'$VERSION-x86_64-windows'"' && zip -r lpm-$FULL_VERSION-x86_64-windows.zip lpm.exe
          cp lpm.exe lpm.x86_64-windows.exe
      - name: Create Release(s)
        env: { GITHUB_TOKEN: "${{ github.token }}" }
        run: |
          gh release delete -y continuous || true; gh release create -t 'Continuous Release' continuous *.zip *.tar.gz
          if [[ `git tag --points-at HEAD | head -c 1` == "v" ]]; then
            gh release delete -y v$VERSION || true;
            gh release create -t v$VERSION v$VERSION lpm.x86_64-linux lpm.x86_64-windows.exe lpm.*-android
            gh release delete -y latest || true;
            gh release create -t latest latest lpm.x86_64-linux lpm.x86_64-windows.exe lpm.*-android
          fi

  build_macos:
    needs: build_linux_android_windows
    runs-on: macos-11
    env:
      CC: clang
    steps:
      - name: Checkout Code
        uses: actions/checkout@v3
        with: { fetch-depth: 0 }
      - name: Set Environment Variables
        run: echo VERSION=`git describe --tags --abbrev=0  --match "v*" | tail -c +2` >> $GITHUB_ENV && echo FULL_VERSION=`git describe --tags --match "v*" | tail -c +2` >> $GITHUB_ENV && echo REV=$((`git describe --tags  --match "v*" | sed 's/.*-\([0-9]*\)-.*/\1/' | sed s/^v.*//` + 1)) >> $GITHUB_ENV
      - name: Clone Submodules
        run: git submodule update --init --depth=1
      - name: Build MacOS
        env: { GITHUB_TOKEN: "${{ github.token }}" }
        run: |
          ./build.sh -DLPM_STATIC -DLPM_VERSION='"'$FULL_VERSION-x86_64-darwin'"' && tar -czvf lpm-$FULL_VERSION-x86_64-darwin.tar.gz lpm
          cp lpm lpm.x86_64-darwin
          ./build.sh clean && CC=clang CFLAGS="-arch arm64" ./build.sh -DLPM_STATIC -DLPM_VERSION='"'$FULL_VERSION-aarch64-darwin'"' && tar -czvf lpm-$FULL_VERSION-aarch64-darwin.tar.gz lpm
          cp lpm lpm.aarch64-darwin
          gh release upload continuous *.tar.gz
          if [[ `git tag --points-at HEAD | head -c 1` == "v" ]]; then
            gh release upload v$VERSION lpm.x86_64-darwin
            gh release upload latest lpm.x86_64-darwin
            gh release upload v$VERSION lpm.aarch64-darwin
            gh release upload latest lpm.aarch64-darwin
            git branch -f latest HEAD
            git tag -f latest
            git push -f origin refs/heads/latest
            git push -f origin refs/tags/latest
          fi