aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/build.yml
blob: 0b1423154f03388d36f4e72a706ce57c5c1f0e56 (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: Build
on: pull_request

jobs:
  build-viewer:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 12.x
      - name: Lint and build Node.js Vue project
        working-directory: viewer
        run: |
          npm install
          npm run lint
          npm run build
      - uses: actions/upload-artifact@v2
        with:
          name: viewer-dist
          path: viewer/dist

  # TODO: do not hard-code the CI install path in the output binary
  # See https://github.com/ldgallery/ldgallery/issues/286
  build-compiler:
    strategy:
      fail-fast: false
      matrix:
        os: [ ubuntu-latest, windows-latest ]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v2
      - uses: actions/cache@v2
        with:
          path: ~/.stack
          key: compiler-${{ runner.os }}-${{ hashFiles('compiler/stack.yaml') }}
      - uses: haskell/actions/setup@v1
        with:
          ghc-version: 8.10.4
          enable-stack: true
      - name: Build Haskell Stack project
        working-directory: compiler
        shell: bash
        run: |
          STACK_ROOT=~/.stack  # make it the same on all platforms
          stack setup --no-terminal
          stack build --no-terminal
          stack install --local-bin-path dist
      - uses: actions/upload-artifact@v2
        with:
          name: compiler-dist-${{ matrix.os }}
          path: compiler/dist

  # TODO: generate a distro-agnostic Linux package.
  # See https://github.com/ldgallery/ldgallery/issues/285
  archive-linux:
    needs: [ build-viewer, build-compiler ]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Bundle ldgallery viewer
        uses: actions/download-artifact@v2
        with:
          name: viewer-dist
          path: dist/viewer
      - name: Bundle ldgallery compiler
        uses: actions/download-artifact@v2
        with:
          name: compiler-dist-ubuntu-latest
          path: dist
      - name: Install build dependencies
        run: |
          sudo apt-get update -qq
          sudo apt-get install -y pandoc
      - name: Build manuals
        run: |
          pandoc --standalone --to man ldgallery-quickstart.7.md --output dist/ldgallery-quickstart.7
          pandoc --standalone --to man compiler/ldgallery.1.md --output dist/ldgallery.1
          pandoc --standalone --to man viewer/ldgallery-viewer.7.md --output dist/ldgallery-viewer.7
          cp changelog.md dist/
          cp license.md dist/
      - uses: actions/upload-artifact@v2
        with:
          name: archive-linux-amd64
          path: dist

  archive-windows:
    needs: [ build-viewer, build-compiler ]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/cache@v2
        with:
          path: ~/downloads
          key: archive-windows-vendored
      - name: Bundle ldgallery viewer
        uses: actions/download-artifact@v2
        with:
          name: viewer-dist
          path: dist/viewer
      - name: Bundle ldgallery compiler
        uses: actions/download-artifact@v2
        with:
          name: compiler-dist-windows-latest
          path: dist
      - name: Install build dependencies
        run: |
          sudo apt-get update -qq
          sudo apt-get install -y pandoc wget curl html-xml-utils p7zip-full
      - name: Copy scripts
        run: |
          mkdir dist/scripts
          cp scripts/win_* dist/scripts/
      - name: Build manuals
        run: |
          pandoc --standalone --to html ldgallery-quickstart.7.md --output dist/ldgallery-quickstart.7.html
          pandoc --standalone --to html compiler/ldgallery.1.md --output dist/ldgallery.1.html
          pandoc --standalone --to html viewer/ldgallery-viewer.7.md --output dist/ldgallery-viewer.7.html
          pandoc --standalone --to html changelog.md --output dist/changelog.html
          pandoc --standalone --to html license.md --output dist/license.html
      - name: Bundle ImageMagick
        run: |
          MAGICK_ARCHIVES="https://download.imagemagick.org/ImageMagick/download/binaries/"
          MAGICK_LATEST=$( \
            curl --silent "$MAGICK_ARCHIVES" \
            | hxclean \
            | hxselect 'a::attr(href)' -c -s '\n' \
            | grep -m1 '^ImageMagick-7.*portable-Q16-x64.zip$' )
          mkdir -p ~/downloads
          wget --timestamping --directory-prefix ~/downloads "$MAGICK_ARCHIVES/$MAGICK_LATEST"
          7z e ~/downloads/"$MAGICK_LATEST" -odist/ magick.exe
          7z e ~/downloads/"$MAGICK_LATEST" -so LICENSE.txt > dist/magick.license.txt
          7z e ~/downloads/"$MAGICK_LATEST" -so NOTICE.txt > dist/magick.notice.txt
          7z e ~/downloads/"$MAGICK_LATEST" -so README.txt > dist/magick.readme.txt
      - uses: actions/upload-artifact@v2
        with:
          name: archive-win64
          path: dist