File size: 2,778 Bytes
13df045
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# This installs the dependencies, zips the files, uploads the artifact, and creates a GitHub release.
# This appears to work for Windows, but in macOS it has permissions issues. Linux not tested.
name: Package and Release

on:
  push:
    tags:
      - '*'

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          # MacOS
          - os: macos-latest
            arch: x86_64
            node: 18
          - os: macos-latest
            arch: arm64
            node: 18
          - os: macos-latest
            arch: x86_64
            node: 20
          - os: macos-latest
            arch: arm64
            node: 20
          # Ubuntu
          - os: ubuntu-latest
            arch: x86_64
            node: 18
          - os: ubuntu-latest
            arch: arm64
            node: 18
          - os: ubuntu-latest
            arch: x86_64
            node: 20
          - os: ubuntu-latest
            arch: arm64
            node: 20
          # Windows
          - os: windows-latest
            arch: x86_64
            node: 18
          - os: windows-latest
            arch: x86_64
            node: 20
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Set up Node.js ${{ matrix.node }}
        uses: actions/setup-node@v2
        with:
          node-version: ${{ matrix.node }}

      - name: Install dependencies
        run: npm install

      - name: Zip files (Windows)
        if: runner.os == 'Windows'
        run: powershell.exe -Command "Compress-Archive -Path . -DestinationPath evidence-${{ matrix.os }}-${{ matrix.arch }}-node${{ matrix.node }}.zip -Force"

      - name: Zip files (Unix)
        if: runner.os != 'Windows'
        run: zip -r evidence-${{ matrix.os }}-${{ matrix.arch }}-node${{ matrix.node }}.zip . -x "*.git*"

      - name: Upload artifact
        uses: actions/upload-artifact@v2
        with:
          name: evidence-${{ matrix.os }}-${{ matrix.arch }}-node${{ matrix.node }}
          path: evidence-${{ matrix.os }}-${{ matrix.arch }}-node${{ matrix.node }}.zip

  release:
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Download all artifacts
        uses: actions/download-artifact@v2
        with:
          path: .

      - name: Create or Update GitHub Release
        uses: ncipollo/release-action@v1
        with:
          artifacts: '**/evidence-*.zip'
          token: ${{ secrets.GH_ACTIONS_RELEASE_TOKEN }}
          tag: ${{ github.ref }}
          name: Release ${{ github.ref_name }}
          body: |
            Release for ${{ github.ref_name }} with artifacts.
          draft: false
          prerelease: false
          allowUpdates: true