-
Notifications
You must be signed in to change notification settings - Fork 7
159 lines (135 loc) · 4.42 KB
/
binaries.yml
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Binaries
on:
push:
branches:
- master
tags:
- v*
pull_request:
branches:
- master
workflow_dispatch:
defaults:
run:
shell: bash
jobs:
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
stack: ["2.9.3"]
ghc: ["9.2.5"]
# The GHC version has to match the one in the stack.yaml file.
env:
STACK: "stack --system-ghc"
steps:
- uses: actions/checkout@v3
- name: Setup Haskell Stack
uses: haskell/actions/setup@v2
id: setup
with:
enable-stack: true
stack-version: ${{ matrix.stack }}
ghc-version: ${{ matrix.ghc }}
- name: Restore cache
uses: actions/cache/restore@v3
id: cache
with:
path: ${{ steps.setup.outputs.stack-root }}
key: ${{ runner.os }}-stack-${{ matrix.stack }}-ghc-${{ matrix.ghc }}-${{ hashFiles('goldplate.cabal', 'stack.yaml', 'stack.yaml.lock') }}
restore-keys: ${{ runner.os }}-stack-${{ matrix.stack }}-ghc-${{ matrix.ghc }}-
- name: Build
run: ${STACK} build
- name: Save cache
uses: actions/cache/save@v3
# Reevaluate key.
env:
key: ${{ runner.os }}-stack-${{ matrix.stack }}-ghc-${{ matrix.ghc }}-${{ hashFiles('goldplate.cabal', 'stack.yaml', 'stack.yaml.lock') }}
# Will fail if we already have a cache with this key.
if: ${{ !(steps.cache.outputs.cache-hit && env.key == steps.cache.outputs.cache-matched-key) }}
with:
path: ${{ steps.setup.outputs.stack-root }}
key: ${{ env.key }}
# Should not error.
# continue-on-error: true
- name: Info about command-line tools used in test-suite
run: |
which bash
which cat
which echo
continue-on-error: true
- name: Info about command-line tools used in test-suite (via stack exec)
run: |
${STACK} exec which bash
${STACK} exec which cat
${STACK} exec which echo
continue-on-error: true
- name: Setup MSYS2 (Windows)
if: ${{ runner.os == 'Windows' }}
run: echo "C:\msys64\mingw64\bin;C:\msys64\usr\bin" >> "${GITHUB_PATH}"
- name: Info about command-line tools used in test-suite
run: |
which bash
which cat
which echo
continue-on-error: true
- name: Info about command-line tools used in test-suite (via stack exec)
run: |
${STACK} exec which bash
${STACK} exec which cat
${STACK} exec which echo
continue-on-error: true
- name: Test
run: ${STACK} test --test-arguments --diff
- name: Get goldplate version
run: |
VERSION="$(${STACK} run -- --numeric-version | tail -1)"
echo "VERSION=${VERSION}" >> "${GITHUB_ENV}"
- name: Create artifact
# if: startsWith(github.ref, 'refs/tags/v')
run: |
PLATFORM="$(uname | tr 'A-Z' 'a-z')"
BIN_DIR="$(${STACK} path --local-install-root)/bin"
EXE=$(cd "${BIN_DIR}"; ls goldplate*)
echo "PLATFORM = ${PLATFORM}"
echo "VERSION = ${VERSION}"
echo "BIN_DIR = ${BIN_DIR}"
echo "EXE = ${EXE}"
cp "${BIN_DIR}/${EXE}" .
tar -czf goldplate.tar.gz "${EXE}"
mkdir -p artifacts
mv goldplate.tar.gz "artifacts/goldplate-${VERSION}-${PLATFORM}-x86_64.tar.gz"
- uses: actions/upload-artifact@v3
# if: startsWith(github.ref, 'refs/tags/v')
with:
path: artifacts/*
name: artifacts
outputs:
version: ${{ env.VERSION }}
release:
name: Release
needs: build
runs-on: ubuntu-latest
# if: startsWith(github.ref, 'refs/tags/v')
steps:
# - name: Get the version
# id: get_version
# run: echo version="${GITHUB_REF#refs/tags/}" >> "${GITHUB_OUTPUT}"
- uses: actions/download-artifact@v3
with:
name: artifacts
- name: Display structure of downloaded files
run: ls -R
- uses: softprops/action-gh-release@v1
env:
VERSION: ${{ needs.build.outputs.version }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: |
goldplate-${{ env.VERSION }}-linux-x86_64.tar.gz
goldplate-${{ env.VERSION }}-darwin-x86_64.tar.gz
goldplate-${{ env.VERSION }}-windows-x86_64.tar.gz
generate_release_notes: true