-
Notifications
You must be signed in to change notification settings - Fork 11
143 lines (140 loc) · 5.1 KB
/
release.yaml
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
name: Release
on:
push:
tags:
- "v*"
jobs:
release:
name: Release
runs-on: ubuntu-20.04
outputs:
release_upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- id: create_release
name: Create the release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: ${{ github.ref }}
draft: true
publish-unix:
name: Publish
needs: release
strategy:
fail-fast: false
matrix:
os:
- ubuntu-20.04
- macos-latest
runs-on: ${{ matrix.os }}
steps:
- name: Check out
uses: actions/checkout@v3
- name: Get GHC version
id: ghc-version
run: echo "ghc-version=$(cat ghc.version)" >> "$GITHUB_OUTPUT"
- name: Set up Haskell
id: haskell-setup
uses: haskell/actions/setup@v2
with:
ghc-version: ${{ steps.ghc-version.outputs.ghc-version }}
enable-stack: true
stack-no-global: true
stack-setup-ghc: true
- name: Cache the Stack directory
uses: actions/cache@v3
with:
path: ${{ steps.haskell-setup.outputs.stack-root }}
key: v1-${{ matrix.os }}-stack-${{ hashFiles('stack.yaml', 'package.yaml') }}
- name: Install dependencies
run: stack --no-terminal install --only-dependencies --test --no-run-tests
- name: Build for release
run: stack --no-terminal install --local-bin-path=./out/build/release
- name: Check version
run: |
TAG='${{ github.ref }}'
EXPECTED_VERSION_STRING="Smoke ${TAG##*/}"
ACTUAL_VERSION_STRING="$(./out/build/release/smoke --version)"
if [[ "$ACTUAL_VERSION_STRING" != "$EXPECTED_VERSION_STRING" ]]; then
echo "Invalid version!"
echo "Expected: ${EXPECTED_VERSION_STRING}"
echo "Actual: ${ACTUAL_VERSION_STRING}"
exit 1
fi
- id: asset
name: Set the asset information
run: |
export TAG='${{ github.ref }}'
echo "asset_name=smoke-${TAG##*/}-$(uname -s)-$(uname -m)" >> "$GITHUB_OUTPUT"
echo "asset_path=out/build/release/smoke" >> "$GITHUB_OUTPUT"
- name: Upload the asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.release_upload_url }}
asset_name: ${{ steps.asset.outputs.asset_name }}
asset_path: ${{ steps.asset.outputs.asset_path }}
asset_content_type: application/octet-stream
publish-windows:
name: Publish (windows-latest)
needs: release
runs-on: windows-latest
steps:
- name: Check out
uses: actions/checkout@v3
- name: Cache Stack
uses: actions/cache@v3
with:
path: C:\Users\runneradmin\AppData\Local\Programs\stack
key: v1-windows-latest-stack-${{ hashFiles('stack.yaml') }}
- name: Get GHC version
id: ghc-version
run: echo "ghc-version=$(Get-Content ghc.version)" >> "$Env:GITHUB_OUTPUT"
- name: Set up Haskell
id: haskell-setup
uses: haskell/actions/setup@v2
with:
ghc-version: ${{ steps.ghc-version.outputs.ghc-version }}
enable-stack: true
stack-no-global: true
stack-setup-ghc: true
- name: Cache the Stack root
uses: actions/cache@v3
with:
path: ${{ steps.haskell-setup.outputs.stack-root }}
key: v1-windows-latest-stack-root-${{ hashFiles('stack.yaml', 'package.yaml') }}
- name: Update MSYS2
run: |
stack --no-terminal exec -- pacman --noconfirm -Sy msys2-keyring
stack --no-terminal exec -- pacman --noconfirm -Syuu
- name: Build for release
run: 'stack --no-terminal install --local-bin-path=.\out\build\release'
- name: Check version
run: |
$ExpectedVersionString = 'Smoke ' + ('${{ github.ref }}' -replace '.+/', '')
$ActualVersionString = .\out\build\release\smoke.exe --version
if ( $ActualVersionString -ne $ExpectedVersionString ) {
echo "Invalid version!"
echo "Expected: ${ExpectedVersionString}"
echo "Actual: ${ActualVersionString}"
exit 1
}
- id: asset
name: Set the asset information
run: |
$Tag = '${{ github.ref }}' -replace '.+/', ''
echo "asset_name=smoke-${Tag}-windows-x64.exe" >> "$Env:GITHUB_OUTPUT"
echo "asset_path=out\build\release\smoke.exe" >> "$Env:GITHUB_OUTPUT"
- name: Upload the asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.release_upload_url }}
asset_name: ${{ steps.asset.outputs.asset_name }}
asset_path: ${{ steps.asset.outputs.asset_path }}
asset_content_type: application/octet-stream