|
| 1 | +name: Build & deploy |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches-ignore: |
| 5 | + - '**' |
| 6 | + tags: |
| 7 | + - 'dev/*.*-dev*' |
| 8 | + - 'rc/*.*-rc*' |
| 9 | + - 'release/*.*' |
| 10 | + |
| 11 | +jobs: |
| 12 | + build-windows: |
| 13 | + name: Build windows release |
| 14 | + runs-on: windows-2019 |
| 15 | + steps: |
| 16 | + - name: Checkout repository |
| 17 | + uses: actions/checkout@v2 |
| 18 | + with: |
| 19 | + submodules: recursive |
| 20 | + lfs: true |
| 21 | + |
| 22 | + - name: Extract version |
| 23 | + id: version |
| 24 | + shell: bash |
| 25 | + run: | |
| 26 | + TAG=${GITHUB_REF/refs\/tags\//} |
| 27 | + echo ::set-output name=BRANCH::${TAG/\/*} |
| 28 | + echo ::set-output name=VERSION::${TAG/*\/} |
| 29 | +
|
| 30 | + - name: Build |
| 31 | + shell: cmd |
| 32 | + run: | |
| 33 | + mkdir build |
| 34 | + pushd build |
| 35 | + cmake -G"Visual Studio 16" -A x64 -DJS_MODULE_VERSION=%VERSION% .. |
| 36 | + cmake --build . --config Release |
| 37 | + popd |
| 38 | + mkdir dist\modules\js-module |
| 39 | + copy build\Release\js-module.dll dist\modules\js-module |
| 40 | + copy deps\nodejs\lib\Release\libnode.dll dist\modules\js-module |
| 41 | + env: |
| 42 | + VERSION: ${{ steps.version.outputs.VERSION }} |
| 43 | + |
| 44 | + - uses: actions/upload-artifact@v2 |
| 45 | + with: |
| 46 | + name: js-module-windows |
| 47 | + path: ./dist/ |
| 48 | + |
| 49 | + build-linux: |
| 50 | + name: Build linux release |
| 51 | + runs-on: ubuntu-18.04 |
| 52 | + steps: |
| 53 | + - name: Checkout repository |
| 54 | + uses: actions/checkout@v2 |
| 55 | + with: |
| 56 | + submodules: recursive |
| 57 | + lfs: true |
| 58 | + |
| 59 | + - name: Extract version |
| 60 | + id: version |
| 61 | + shell: bash |
| 62 | + run: | |
| 63 | + TAG=${GITHUB_REF/refs\/tags\//} |
| 64 | + echo ::set-output name=BRANCH::${TAG/\/*} |
| 65 | + echo ::set-output name=VERSION::${TAG/*\/} |
| 66 | +
|
| 67 | + - name: Build |
| 68 | + run: | |
| 69 | + sudo add-apt-repository ppa:ubuntu-toolchain-r/test |
| 70 | + sudo apt-get update |
| 71 | + sudo apt-get install gcc-8 g++-8 |
| 72 | + mkdir build-linux && cd build-linux |
| 73 | + cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=g++-8 -DJS_MODULE_VERSION=%VERSION% .. |
| 74 | + cmake --build . --config Release |
| 75 | + cd .. |
| 76 | + mkdir -p dist/modules/js-module |
| 77 | + cp ./build-linux/libjs-module.so dist/modules/js-module |
| 78 | + cp ./deps/nodejs/lib/libnode.so.83 dist/modules/js-module |
| 79 | + env: |
| 80 | + VERSION: ${{ steps.version.outputs.VERSION }} |
| 81 | + |
| 82 | + - uses: actions/upload-artifact@v2 |
| 83 | + with: |
| 84 | + name: js-module-linux |
| 85 | + path: ./dist/ |
| 86 | + |
| 87 | + deploy-cdn: |
| 88 | + name: Deploy release to alt:V CDN |
| 89 | + runs-on: ubuntu-18.04 |
| 90 | + needs: [build-linux, build-windows] |
| 91 | + steps: |
| 92 | + - name: Set up Node.js |
| 93 | + uses: actions/setup-node@v1 |
| 94 | + with: |
| 95 | + node-version: 12.x |
| 96 | + |
| 97 | + - name: Cache node_modules |
| 98 | + uses: actions/cache@v2 |
| 99 | + with: |
| 100 | + path: '**/node_modules' |
| 101 | + key: ${{ runner.os }} |
| 102 | + |
| 103 | + - name: Download windows artifacts |
| 104 | + uses: actions/download-artifact@v2 |
| 105 | + with: |
| 106 | + name: js-module-windows |
| 107 | + path: dist-windows |
| 108 | + |
| 109 | + - name: Download linux artifacts |
| 110 | + uses: actions/download-artifact@v2 |
| 111 | + with: |
| 112 | + name: js-module-linux |
| 113 | + path: dist-linux |
| 114 | + |
| 115 | + - name: Extract version |
| 116 | + id: version |
| 117 | + shell: bash |
| 118 | + run: | |
| 119 | + TAG=${GITHUB_REF/refs\/tags\//} |
| 120 | + echo ::set-output name=BRANCH::${TAG/\/*} |
| 121 | + echo ::set-output name=VERSION::${TAG/*\/} |
| 122 | +
|
| 123 | + - name: Install upload tool |
| 124 | + run: npm i @altmp/upload-tool@latest |
| 125 | + |
| 126 | + - name: Deploy windows artifacts to cdn |
| 127 | + run: npx alt-upload dist-windows js-module/$BRANCH/x64_win32 $VERSION |
| 128 | + env: |
| 129 | + CI_UPLOAD_URL: ${{ secrets.CI_UPLOAD_URL }} |
| 130 | + CI_DEPLOY_TOKEN: ${{ secrets.CI_DEPLOY_TOKEN }} |
| 131 | + BRANCH: ${{ steps.version.outputs.BRANCH }} |
| 132 | + VERSION: ${{ steps.version.outputs.VERSION }} |
| 133 | + |
| 134 | + - name: Deploy linux artifacts to cdn |
| 135 | + run: npx alt-upload dist-linux js-module/$BRANCH/x64_linux $VERSION |
| 136 | + env: |
| 137 | + CI_UPLOAD_URL: ${{ secrets.CI_UPLOAD_URL }} |
| 138 | + CI_DEPLOY_TOKEN: ${{ secrets.CI_DEPLOY_TOKEN }} |
| 139 | + BRANCH: ${{ steps.version.outputs.BRANCH }} |
| 140 | + VERSION: ${{ steps.version.outputs.VERSION }} |
| 141 | + |
| 142 | + create-release: |
| 143 | + name: Create GitHub Release |
| 144 | + runs-on: ubuntu-18.04 |
| 145 | + needs: [build-linux, build-windows] |
| 146 | + steps: |
| 147 | + - name: Download windows artifacts |
| 148 | + uses: actions/download-artifact@v2 |
| 149 | + with: |
| 150 | + name: js-module-windows |
| 151 | + path: dist-windows |
| 152 | + |
| 153 | + - name: Download linux artifacts |
| 154 | + uses: actions/download-artifact@v2 |
| 155 | + with: |
| 156 | + name: js-module-linux |
| 157 | + path: dist-linux |
| 158 | + |
| 159 | + - name: Zip artifacts |
| 160 | + run: | |
| 161 | + zip -r -j js-module-windows dist-windows |
| 162 | + zip -r -j js-module-linux dist-linux |
| 163 | +
|
| 164 | + - name: Extract version |
| 165 | + id: version |
| 166 | + shell: bash |
| 167 | + run: | |
| 168 | + TAG=${GITHUB_REF/refs\/tags\//} |
| 169 | + echo ::set-output name=BRANCH::${TAG/\/*} |
| 170 | + echo ::set-output name=VERSION::${TAG/*\/} |
| 171 | +
|
| 172 | + - name: Create Release |
| 173 | + id: create_release |
| 174 | + uses: actions/create-release@v1 |
| 175 | + env: |
| 176 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 177 | + with: |
| 178 | + tag_name: ${{ github.ref }} |
| 179 | + release_name: Release ${{ steps.version.outputs.VERSION }} |
| 180 | + |
| 181 | + - name: Upload windows artifacts |
| 182 | + uses: actions/upload-release-asset@v1 |
| 183 | + env: |
| 184 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 185 | + with: |
| 186 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 187 | + asset_path: ./js-module-windows.zip |
| 188 | + asset_name: js-module-windows.zip |
| 189 | + asset_content_type: application/zip |
| 190 | + |
| 191 | + - name: Upload linux artifacts |
| 192 | + uses: actions/upload-release-asset@v1 |
| 193 | + env: |
| 194 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 195 | + with: |
| 196 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 197 | + asset_path: ./js-module-linux.zip |
| 198 | + asset_name: js-module-linux.zip |
| 199 | + asset_content_type: application/zip |
| 200 | + |
| 201 | + delete-artifacts: |
| 202 | + name: Delete artifacts |
| 203 | + runs-on: ubuntu-18.04 |
| 204 | + needs: [ create-release, deploy-cdn ] |
| 205 | + if: ${{ always() }} |
| 206 | + steps: |
| 207 | + - name: Delete artifacts |
| 208 | + uses: geekyeggo/delete-artifact@v1 |
| 209 | + with: |
| 210 | + name: | |
| 211 | + js-module-linux |
| 212 | + js-module-windows |
0 commit comments