-
Notifications
You must be signed in to change notification settings - Fork 132
142 lines (132 loc) Β· 4.33 KB
/
release.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
name: release
on:
push:
tags:
- '*'
env:
STACK_VERSION: '2.9.1'
jobs:
draft_release:
name: Create release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: ""
draft: false
prerelease: false
commitish: master
build_release:
name: Build/upload release
needs: draft_release
runs-on: ${{ matrix.os }}
container: ${{ matrix.image }}
strategy:
matrix:
include:
- os: ubuntu-latest
image: haskell:9.2.8
- os: macOS-latest
- os: windows-latest
steps:
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
git config --global core.longpaths true
- uses: actions/checkout@v4
- name: Setup Haskell (macOS and Windows)
if: runner.os != 'Linux'
uses: haskell-actions/setup@v2
with:
stack-version: ${{ env.STACK_VERSION }}
enable-stack: true
stack-no-global: true
- name: Check Stack version and fix root access (Linux)
if: runner.os == 'Linux'
run: |
[ "$(stack --numeric-version)" = "$STACK_VERSION" ]
chown root:root .
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 22
# NB: We install gnu-tar because BSD tar is buggy on Github's macos machines,
# and it breaks the cache: https://github.com/actions/cache/issues/403
- name: Install GNU tar (macOS)
if: runner.os == 'macOS'
run: |
brew install gnu-tar
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
- name: Package binary (Linux and macOS)
if: runner.os != 'Windows'
shell: bash
run: |
./scripts/fix-home make
./scripts/fix-home stack install --dependencies-only
mkdir artifacts
./scripts/fix-home stack build --copy-bins --local-bin-path ./artifacts
cp artifacts/spago spago
strip spago
tar -zcvf "${{ runner.os }}.tar.gz" spago
- name: Package binary (Windows)
if: runner.os == 'Windows'
shell: bash
run: |
make
stack install --dependencies-only
stack build --copy-bins --local-bin-path ./artifacts
cp artifacts/spago.exe spago.exe
tar -zcvf ${{ runner.os }}.tar.gz spago.exe
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.draft_release.outputs.upload_url }}
asset_path: ./${{ runner.os }}.tar.gz
asset_name: ${{ runner.os }}.tar.gz
asset_content_type: application/gzip
- name: Package Checksum
shell: bash
run: ./scripts/checksum ${{ runner.os }}.tar.gz ${{ runner.os }}.sha1
- name: Upload Checksum Asset
id: upload-checksum-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.draft_release.outputs.upload_url }}
asset_path: ./${{ runner.os }}.sha1
asset_name: ${{ runner.os }}.sha1
asset_content_type: text/plain
npm_publish:
name: Publish package on npm
needs: build_release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Publish to NPM
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
sed -e "s/NPM_VERSION/$(./scripts/get-version)/g" -i npm/package.json
sed -e "s/PACKAGE_VERSION/$(./scripts/get-version)/g" -i npm/install.js
cd npm
cp ../README.md ./README.md
cp ../CONTRIBUTING.md ./CONTRIBUTING.md
cp ../LICENSE ./LICENSE
npm publish --non-interactive --access public