cncjs

Форк
0
/
build.yml 
283 строки · 11.5 Кб
1
name: CI
2

3
on:
4
  # https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#example-including-branches-and-tags
5
  push:
6
    # Sequence of patterns matched against refs/heads
7
    branches:
8
      - master
9
    # Sequence of patterns matched against refs/tags
10
    tags:
11
      - '*'
12
  pull_request:
13
    branches: [ "master" ]
14

15
jobs:
16
  build-linux:
17
    name: Build Linux packages
18
    runs-on: ubuntu-latest
19
    strategy:
20
      matrix:
21
        node-version: [14.x]
22
    env:
23
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24
    steps:
25
    - name: Checkout code
26
      uses: actions/checkout@v3
27
    - name: Setup Node.js ${{ matrix.node-version }}
28
      uses: actions/setup-node@v3
29
      with:
30
        node-version: ${{ matrix.node-version }}
31
    - name: Environment variables
32
      run: |
33
        # https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
34
        echo "• GITHUB_REF_NAME=$GITHUB_REF_NAME"
35
        echo "• GITHUB_REF_TYPE=$GITHUB_REF_TYPE" # `branch` or `tag`
36
        echo "• GITHUB_RUN_NUMBER=$GITHUB_RUN_NUMBER"
37
        echo "• GITHUB_SHA=$GITHUB_SHA"
38
        echo "• RUNNER_ARCH=$RUNNER_ARCH"
39
        echo "• RUNNER_NAME=$RUNNER_NAME"
40
        echo "• RUNNER_OS=$RUNNER_OS"
41
        echo "• RUNNER_TEMP=$RUNNER_TEMP"
42
        echo "• RUNNER_TOOL_CACHE=$RUNNER_TOOL_CACHE"
43
    - name: Install Yarn package manager
44
      run: npm install -g yarn
45
    - name: Install necessary dependencies and perform initial checks
46
      run: |
47
        yarn up
48
        yarn install
49
        yarn lint
50
        yarn test
51
    - name: Run "build" script
52
      if: github.ref_type == 'tag'
53
      run: yarn run build
54
    - name: Run "build-latest" script
55
      if: github.ref_type == 'branch'
56
      run: yarn run build-latest
57
    - name: Build Linux binaries
58
      run: |
59
        yarn run build:linux
60
    - name: Prepare release assets
61
      shell: bash
62
      run: |
63
        GIT_COMMIT_LOG=`git log -1 --format='%ci %H %s'`
64
        PRODUCT_NAME=CNCjs
65
        PACKAGE_NAME=`node -e "console.log(require('./src/package.json').name)"`
66
        PACKAGE_VERSION=`node -e "console.log(require('./src/package.json').version)"`
67
        mkdir -p releases/linux
68
        cp -af "output/${PACKAGE_NAME}-${PACKAGE_VERSION}.x86_64.rpm" "releases/linux/${PACKAGE_NAME}-${PACKAGE_VERSION}-linux.x86_64.rpm"
69
        cp -af "output/${PRODUCT_NAME}-${PACKAGE_VERSION}.AppImage" "releases/linux/${PACKAGE_NAME}-${PACKAGE_VERSION}-linux-x86_64.AppImage"
70
        cp -af "output/${PACKAGE_NAME}_${PACKAGE_VERSION}_amd64.deb" "releases/linux/${PACKAGE_NAME}-${PACKAGE_VERSION}-linux-amd64.deb"
71
        cp -af "output/${PACKAGE_NAME}-${PACKAGE_VERSION}.armv7l.rpm" "releases/linux/${PACKAGE_NAME}-${PACKAGE_VERSION}-linux.armv7l.rpm"
72
        cp -af "output/${PRODUCT_NAME}-${PACKAGE_VERSION}-armv7l.AppImage" "releases/linux/${PACKAGE_NAME}-${PACKAGE_VERSION}-linux-armv7l.AppImage"
73
        cp -af "output/${PACKAGE_NAME}_${PACKAGE_VERSION}_armv7l.deb" "releases/linux/${PACKAGE_NAME}-${PACKAGE_VERSION}-linux-armv7l.deb"
74
        cp -af "output/${PACKAGE_NAME}-${PACKAGE_VERSION}.aarch64.rpm" "releases/linux/${PACKAGE_NAME}-${PACKAGE_VERSION}-linux.aarch64.rpm"
75
        cp -af "output/${PRODUCT_NAME}-${PACKAGE_VERSION}-arm64.AppImage" "releases/linux/${PACKAGE_NAME}-${PACKAGE_VERSION}-linux-arm64.AppImage"
76
        cp -af "output/${PACKAGE_NAME}_${PACKAGE_VERSION}_arm64.deb" "releases/linux/${PACKAGE_NAME}-${PACKAGE_VERSION}-linux-arm64.deb"
77
        pushd releases/linux
78
        ln -sf ../../output/linux-unpacked "${PACKAGE_NAME}-${PACKAGE_VERSION}-linux-x64"
79
        tar zcfh "${PACKAGE_NAME}-${PACKAGE_VERSION}-linux-x64.tar.gz" "${PACKAGE_NAME}-${PACKAGE_VERSION}-linux-x64"
80
        rm -f "${PACKAGE_NAME}-${PACKAGE_VERSION}-linux-x64"
81
        ln -sf ../../output/linux-armv7l-unpacked "${PACKAGE_NAME}-${PACKAGE_VERSION}-linux-armv7l"
82
        tar zcfh "${PACKAGE_NAME}-${PACKAGE_VERSION}-linux-armv7l.tar.gz" "${PACKAGE_NAME}-${PACKAGE_VERSION}-linux-armv7l"
83
        rm -f "${PACKAGE_NAME}-${PACKAGE_VERSION}-linux-armv7l"
84
        ln -sf ../../output/linux-arm64-unpacked "${PACKAGE_NAME}-${PACKAGE_VERSION}-linux-arm64"
85
        tar zcfh "${PACKAGE_NAME}-${PACKAGE_VERSION}-linux-arm64.tar.gz" "${PACKAGE_NAME}-${PACKAGE_VERSION}-linux-arm64"
86
        rm -f "${PACKAGE_NAME}-${PACKAGE_VERSION}-linux-arm64"
87
        popd
88
        ls -al output releases/linux
89
        if [[ "$GITHUB_REF_TYPE" == "branch" && "$GITHUB_REF_NAME" == "master" ]]; then
90
          yarn github-release delete \
91
            --owner=cncjs \
92
            --repo=cncjs \
93
            --tag="${GITHUB_REF_NAME}-latest" \
94
            --release-name="${GITHUB_REF_NAME}" \
95
            "*-linux*";
96
          yarn github-release upload \
97
            --owner=cncjs \
98
            --repo=cncjs \
99
            --tag="${GITHUB_REF_NAME}-latest" \
100
            --release-name="${GITHUB_REF_NAME}" \
101
            --body="${GIT_COMMIT_LOG}" \
102
            releases/linux/*;
103
        fi
104
    #- name: Upload release assets
105
    #  uses: actions/github-script@v6
106
    #  with:
107
    #    github-token: ${{ secrets.GITHUB_TOKEN }}
108
    #    script: |
109
    #      // https://github.com/actions/upload-release-asset/issues/47#issuecomment-659071145
110
    #      console.log('environment:', process.versions);
111
    - name: Release
112
      uses: softprops/action-gh-release@v1
113
      if: startsWith(github.ref, 'refs/tags/')
114
      with:
115
        files: |
116
          releases/linux/*
117

118
  build-macos:
119
    name: Build macOS packages
120
    runs-on: macos-latest
121
    strategy:
122
      matrix:
123
        node-version: [14.x]
124
    env:
125
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
126
    steps:
127
    - name: Checkout code
128
      uses: actions/checkout@v3
129
    - name: Setup Node.js ${{ matrix.node-version }}
130
      uses: actions/setup-node@v3
131
      with:
132
        node-version: ${{ matrix.node-version }}
133
    - name: Environment variables
134
      run: |
135
        # https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
136
        echo "• GITHUB_REF_NAME=$GITHUB_REF_NAME"
137
        echo "• GITHUB_REF_TYPE=$GITHUB_REF_TYPE" # `branch` or `tag`
138
        echo "• GITHUB_RUN_NUMBER=$GITHUB_RUN_NUMBER"
139
        echo "• GITHUB_SHA=$GITHUB_SHA"
140
        echo "• RUNNER_ARCH=$RUNNER_ARCH"
141
        echo "• RUNNER_NAME=$RUNNER_NAME"
142
        echo "• RUNNER_OS=$RUNNER_OS"
143
        echo "• RUNNER_TEMP=$RUNNER_TEMP"
144
        echo "• RUNNER_TOOL_CACHE=$RUNNER_TOOL_CACHE"
145
    - name: Install Yarn package manager
146
      run: npm install -g yarn
147
    - name: Install necessary dependencies and perform initial checks
148
      run: |
149
        yarn up
150
        yarn install
151
        yarn lint
152
        yarn test
153
    - name: Run "build" script
154
      if: github.ref_type == 'tag'
155
      run: yarn run build
156
    - name: Run "build-latest" script
157
      if: github.ref_type == 'branch'
158
      run: yarn run build-latest
159
    - name: Build macOS binaries
160
      run: yarn run build:macos
161
    - name: Prepare release assets
162
      shell: bash
163
      run: |
164
        GIT_COMMIT_LOG=`git log -1 --format='%ci %H %s'`
165
        PRODUCT_NAME=CNCjs
166
        PACKAGE_NAME=`node -e "console.log(require('./src/package.json').name)"`
167
        PACKAGE_VERSION=`node -e "console.log(require('./src/package.json').version)"`
168
        mkdir -p releases/macos
169
        cp -af "output/${PRODUCT_NAME}-${PACKAGE_VERSION}.dmg" "releases/macos/${PACKAGE_NAME}-${PACKAGE_VERSION}-macos-x64.dmg"
170
        cp -af "output/${PRODUCT_NAME}-${PACKAGE_VERSION}-arm64.dmg" "releases/macos/${PACKAGE_NAME}-${PACKAGE_VERSION}-macos-arm64.dmg"
171
        ls -al output releases/macos
172
        if [[ "$GITHUB_REF_TYPE" == "branch" && "$GITHUB_REF_NAME" == "master" ]]; then
173
          yarn github-release delete \
174
            --owner=cncjs \
175
            --repo=cncjs \
176
            --tag="${GITHUB_REF_NAME}-latest" \
177
            --release-name="${GITHUB_REF_NAME}" \
178
            "*-macos*";
179
          yarn github-release upload \
180
            --owner=cncjs \
181
            --repo=cncjs \
182
            --tag="${GITHUB_REF_NAME}-latest" \
183
            --release-name="${GITHUB_REF_NAME}" \
184
            --body="${GIT_COMMIT_LOG}" \
185
            releases/macos/*;
186
        fi
187
    #- name: Upload release assets
188
    #  uses: actions/github-script@v6
189
    #  with:
190
    #    github-token: ${{ secrets.GITHUB_TOKEN }}
191
    #    script: |
192
    #      // https://github.com/actions/upload-release-asset/issues/47#issuecomment-659071145
193
    #      console.log('environment:', process.versions);
194
    - name: Release
195
      uses: softprops/action-gh-release@v1
196
      if: startsWith(github.ref, 'refs/tags/')
197
      with:
198
        files: |
199
          releases/macos/*
200

201
  build-windows:
202
    name: Build Windows packages
203
    runs-on: windows-latest
204
    strategy:
205
      matrix:
206
        node-version: [14.x]
207
    env:
208
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
209
    steps:
210
    - name: Prepare VC++ Runtime
211
      run: choco install -y vcredist2017
212
    - name: Checkout code
213
      uses: actions/checkout@v3
214
    - name: Setup Node.js ${{ matrix.node-version }}
215
      uses: actions/setup-node@v3
216
      with:
217
        node-version: ${{ matrix.node-version }}
218
    - name: Environment variables
219
      run: |
220
        # https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
221
        echo "• GITHUB_REF_NAME=$GITHUB_REF_NAME"
222
        echo "• GITHUB_REF_TYPE=$GITHUB_REF_TYPE" # `branch` or `tag`
223
        echo "• GITHUB_RUN_NUMBER=$GITHUB_RUN_NUMBER"
224
        echo "• GITHUB_SHA=$GITHUB_SHA"
225
        echo "• RUNNER_ARCH=$RUNNER_ARCH"
226
        echo "• RUNNER_NAME=$RUNNER_NAME"
227
        echo "• RUNNER_OS=$RUNNER_OS"
228
        echo "• RUNNER_TEMP=$RUNNER_TEMP"
229
        echo "• RUNNER_TOOL_CACHE=$RUNNER_TOOL_CACHE"
230
    - name: Install Yarn package manager
231
      run: npm install -g yarn
232
    - name: Install necessary dependencies and perform initial checks
233
      run: |
234
        yarn up
235
        yarn install
236
        yarn lint
237
        yarn test
238
    - name: Run "build" script
239
      if: github.ref_type == 'tag'
240
      run: yarn run build
241
    - name: Run "build-latest" script
242
      if: github.ref_type == 'branch'
243
      run: yarn run build-latest
244
    - name: Build Windows binaries
245
      run: yarn run build:windows
246
    - name: Prepare release assets
247
      shell: bash
248
      run: |
249
        GIT_COMMIT_LOG=`git log -1 --format='%ci %H %s'`
250
        PRODUCT_NAME=CNCjs
251
        PACKAGE_NAME=`node -e "console.log(require('./src/package.json').name)"`
252
        PACKAGE_VERSION=`node -e "console.log(require('./src/package.json').version)"`
253
        mkdir -p releases/windows
254
        cp -af "output/${PRODUCT_NAME} Setup ${PACKAGE_VERSION}.exe" "releases/windows/${PACKAGE_NAME}-${PACKAGE_VERSION}-windows-x64.exe"
255
        ls -al output releases/windows
256
        if [[ "$GITHUB_REF_TYPE" == "branch" && "$GITHUB_REF_NAME" == "master" ]]; then
257
          yarn github-release delete \
258
            --owner=cncjs \
259
            --repo=cncjs \
260
            --tag="${GITHUB_REF_NAME}-latest" \
261
            --release-name="${GITHUB_REF_NAME}" \
262
            "*-windows*";
263
          yarn github-release upload \
264
            --owner=cncjs \
265
            --repo=cncjs \
266
            --tag="${GITHUB_REF_NAME}-latest" \
267
            --release-name="${GITHUB_REF_NAME}" \
268
            --body="${GIT_COMMIT_LOG}" \
269
            releases/windows/*;
270
        fi
271
    #- name: Upload release assets
272
    #  uses: actions/github-script@v6
273
    #  with:
274
    #    github-token: ${{ secrets.GITHUB_TOKEN }}
275
    #    script: |
276
    #      // https://github.com/actions/upload-release-asset/issues/47#issuecomment-659071145
277
    #      console.log('environment:', process.versions);
278
    - name: Release
279
      uses: softprops/action-gh-release@v1
280
      if: startsWith(github.ref, 'refs/tags/')
281
      with:
282
        files: |
283
          releases/windows/*
284

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.