forked from haskell/haskell-language-server
-
Notifications
You must be signed in to change notification settings - Fork 0
174 lines (150 loc) · 5.7 KB
/
build.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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'HLS version'
required: true
type: string
tag:
description: 'HLS tag'
required: false
type: string
project:
description: 'Gitlab project number'
type: number
required: false
default: 1180
release:
types: [created]
jobs:
# generates a custom tarball with sources, used by `ghcup compile hls`
src-tar:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v3
- name: Set hls release version
run: |
HLS_VER="${{ github.event.release.tag_name }}"
if [[ -z $HLS_VER ]]; then
HLS_VER=${{ github.sha }}
HLS_VER=${HLS_VER:0:5}
fi
echo "HLS_VER=$HLS_VER" >> $GITHUB_ENV
- name: Create source tarball
run: |
mkdir src-dist
git archive --prefix=haskell-language-server-${{ env.HLS_VER }}/ \
--format=tar.gz \
-o src-dist/haskell-language-server.tar.gz \
HEAD
- name: Upload source tarball to the release
if: ${{ github.event.release.upload_url != '' }}
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: src-dist/haskell-language-server.tar.gz
asset_name: haskell-language-server-${{ env.HLS_VER }}-src.tar.gz
asset_content_type: application/gzip
- name: Upload source tarball to workflow artifacts
uses: actions/upload-artifact@v3
with:
name: haskell-language-server-${{ env.HLS_VER }}-src.tar.gz
path: src-dist/haskell-language-server.tar.gz
# this generates .gz tarfiles containing binaries for all GHC versions and OS's
# used by `ghcup install hls`
tar:
runs-on: ubuntu-latest
steps:
- name: Download tarballs from gitlab
run: |
set -eux
if [ -n "${{ github.event.inputs.project }}" ] ; then
proj=${{ github.event.inputs.project }}
else
proj=1180
fi
if [ -n "${{ github.event.release.tag_name }}" ] ; then
tag=${{ github.event.release.tag_name }}
ver=${tag#v}
elif [ -n "${{ github.event.inputs.version }}" ] ; then
ver=${{ github.event.inputs.version }}
if [ -n "${{ github.event.inputs.tag }}" ] ; then
tag=${{ github.event.inputs.tag }}
else
tag=v${ver}
fi
fi
base_url="https://gitlab.haskell.org/api/v4/projects/${proj}/jobs/artifacts/${tag}/raw"
# unix like platforms
for plat in aarch64-apple-darwin \
aarch64-deb10-linux \
armv7-deb10-linux \
x86_64-apple-darwin \
x86_64-unknown-freebsd12 \
x86_64-unknown-freebsd13 \
x86_64-alpine3.12-linux \
x86_64-centos7-linux \
x86_64-deb9-linux \
x86_64-deb10-linux \
x86_64-fedora27-linux ; do
url="${base_url}/out/haskell-language-server-${ver}-${plat}.tar.xz?job=tar-$(echo "${plat/alpine3.12/alpine}" | awk -F '-' '{ print ($3 == "darwin" || $2 == "unknown") ? $1 "-" $3 : $1 "-" $3 "-" $2 }')"
curl -f -o "haskell-language-server-${ver}-${plat}.tar.xz" "${url}"
done
unset plat url
# windows
curl -f -o "haskell-language-server-${ver}-x86_64-unknown-mingw32.zip" \
"${base_url}/out/haskell-language-server-${ver}-x86_64-unknown-mingw32.zip?job=tar-x86_64-windows"
pwd
ls -lah
# from https://github.com/actions/upload-release-asset/issues/47#issuecomment-659071145
- name: Upload binaries tarball to the release
if: ${{ github.event.release.upload_url != '' }}
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
console.log('environment', process.versions);
const fs = require('fs').promises;
const { repo: { owner, repo }, sha } = context;
console.log({ owner, repo, sha });
for (let file of await fs.readdir('.')) {
console.log('uploading', file);
await github.repos.uploadReleaseAsset({
owner, repo,
release_id: ${{ github.event.release.id }},
name: file,
data: await fs.readFile(`./${file}`)
});
}
- name: Upload binaries tarball to workflow artifacts
uses: actions/upload-artifact@v3
with:
path: ${{ github.workspace }}/*
sha256sum:
needs: [tar, src-tar]
runs-on: ubuntu-18.04
steps:
- uses: actions/download-artifact@v3
- name: Generate sha256 sums for all workflow artifacts
run: |
sha256sum --tag haskell-language-server*/* >> SHA256SUMS
# we clean up tags to match the release file names
sed -i 's/\/.*)/)/g' SHA256SUMS
- name: Upload sha256sums to the release
if: ${{ github.event.release.upload_url != '' }}
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: SHA256SUMS
asset_name: SHA256SUMS
asset_content_type: plain/text
- name: Upload sha256sums to workflow artifacts
uses: actions/upload-artifact@v3
with:
name: SHA256SUMS
path: SHA256SUMS