-
Notifications
You must be signed in to change notification settings - Fork 273
143 lines (121 loc) · 4.33 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"
run-name: "release ${{inputs.version}}"
defaults:
run:
shell: bash
# Current workflow:
# 1. Build the project on Linux, MacOS, and Windows.
# 2. Create a release from the artifacts.
on:
workflow_dispatch:
inputs:
version:
description: 'Release Version (E.g. M4 or M4a or 0.4.1)'
required: true
type: string
target:
description: 'Ref to use for this release, defaults to trunk'
required: true
default: 'trunk'
type: string
jobs:
release:
name: "create_release"
runs-on: ubuntu-20.04
needs:
- build-ucm
steps:
- uses: actions/checkout@v2
with:
ref: release/${{inputs.version}}
- name: make download dir
run: "mkdir /tmp/ucm"
- name: "download artifacts"
uses: actions/download-artifact@v2
with:
path: /tmp/ucm
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
version="${{inputs.version}}"
target="${{inputs.target}}"
# E.g. M4a -> M4, M4c -> M4b, M4 -> M3
prev_version=0.5.19 #"$(${{ github.workspace }}/scripts/previous-tag.sh "${version}")"
echo "Creating a release from these artifacts:"
ls -R /tmp/ucm
gh release create "release/${version}" --target "${target}" --generate-notes --notes-start-tag "release/${prev_version}" /tmp/ucm/**/*.tar.gz /tmp/ucm/**/*.zip
build-ucm:
name: build ucm ${{matrix.os}}
runs-on: ${{matrix.os}}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-12, windows-2019]
steps:
- uses: actions/checkout@v2
with:
ref: release/${{inputs.version}}
- name: restore stack caches
uses: ./.github/workflows/actions/restore-stack-cache
with:
cache-prefix: release
work-cache-prefix: release
- name: install stack
uses: ./.github/workflows/actions/install-stack
- name: build
run: |
# unison-cli embeds version numbers using TH
# so it needs to be forced to rebuild to ensure those are updated.
stack clean unison-cli
# Windows will crash on build intermittently because the filesystem
# sucks at managing concurrent file access;
# Just keep retrying on these failures.
tries=5
for (( i = 0; i < $tries; i++ )); do
stack --no-terminal build --flag unison-parser-typechecker:optimized && break;
done
- name: save stack caches
uses: ./.github/workflows/actions/save-stack-cache
with:
cache-prefix: release
work-cache-prefix: release
- name: set up environment
run: |
if [[ ${{runner.os}} = 'Windows' ]]; then
artifact_os="windows"
elif [[ ${{runner.os}} = 'macOS' ]]; then
artifact_os="osx"
elif [[ ${{runner.os}} = 'Linux' ]]; then
artifact_os="linux"
else
echo "Unexpected OS: ${{runner.os}}"
exit 1
fi
echo "artifact_os=$artifact_os" >> $GITHUB_ENV
- name: fetch latest Unison Local UI and package with ucm
run: |
mkdir -p /tmp/ucm/ui # we need /tmp/ucm on the next line and /tmp/ucm/ui further down
if [[ ${{runner.os}} = 'Windows' ]]; then
cp $(stack exec -- where unison) /tmp/ucm/ucm.exe
wget="C:/msys64/usr/bin/wget.exe"
else
cp $(stack exec -- which unison) /tmp/ucm/ucm
wget="wget"
fi
$wget -O/tmp/unisonLocal.zip https://github.com/unisonweb/unison-local-ui/releases/download/latest/unisonLocal.zip
unzip -d /tmp/ucm/ui /tmp/unisonLocal.zip
if [[ ${{runner.os}} = 'Windows' ]]; then
artifact_archive=ucm-${{env.artifact_os}}.tar.gz
zip -r ${artifact_archive} /tmp/ucm
else
artifact_archive=ucm-${{env.artifact_os}}.tar.gz
tar -c -z -f ${artifact_archive} -C /tmp/ucm .
fi
echo "artifact_archive=${artifact_archive}" >> $GITHUB_ENV
- name: upload artifact
uses: actions/upload-artifact@v2
with:
if-no-files-found: error
name: build-${{env.artifact_os}}
path: ${{env.artifact_archive}}