-
Notifications
You must be signed in to change notification settings - Fork 19
160 lines (153 loc) · 6.52 KB
/
on-demand-deployment.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: on-demand-deployment
on:
release:
types: [edited]
jobs:
setup:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
run-installer: ${{ steps.set-matrix.outputs.run-installer }}
steps:
- name: Get the tag
id: get-tag
shell: bash
run: |
echo "Setting tag as: ${GITHUB_REF#refs/tags/}"
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Get the release name
id: get-release-name
shell: bash
run: |
tag=${GITHUB_REF#refs/tags/}
bare_tag=${tag/v/}
IFS='.' read -ra bare_tag_parts <<< "$bare_tag"
name="${bare_tag_parts[0]}.${bare_tag_parts[1]}.${bare_tag_parts[2]}"
echo "Setting name as: ${name}"
echo "name=$name" >> $GITHUB_OUTPUT
- name: Determine required assets
id: req-assets
shell: cmake -P {0}
run: |
set(RELEASE_BODY "${{ github.event.release.body }}")
string(REPLACE "\n" ";" _PARTS "${RELEASE_BODY}")
foreach(_PART ${_PARTS})
string(STRIP "${_PART}" _PART)
if ("${_PART}" STREQUAL "[odd release with mapping tools]")
message(STATUS "Require a MAP Client mapping tools variant.")
file(APPEND $ENV{GITHUB_OUTPUT} "include_mapping_tools=true\n")
endif()
if ("${_PART}" STREQUAL "[odd release with installer]")
message(STATUS "Require a MAP Client installer.")
file(APPEND $ENV{GITHUB_OUTPUT} "include_installer=true\n")
endif()
endforeach()
- name: set_matrix
id: set-matrix
run: |
function join_by { local IFS="$1"; shift; echo "$*"; }
matrixElements=()
if [ "${{ steps.req-assets.outputs.include_installer }}" == "true" ]; then
matrixElements+=('{"os":"windows-2019","variant":"mapclient","tag":"${{ steps.get-tag.outputs.tag }}","release-name":"${{ steps.get-release-name.outputs.name }}","python-version":"3.9"}')
matrixElements+=('{"os":"macos-11","variant":"mapclient","tag":"${{ steps.get-tag.outputs.tag }}","release-name":"${{ steps.get-release-name.outputs.name }}","python-version":"3.9"}')
fi
if [ "${{ steps.req-assets.outputs.include_mapping_tools }}" == "true" ]; then
matrixElements+=('{"os":"windows-2019","variant":"mapping-tools","tag":"${{ steps.get-tag.outputs.tag }}","release-name":"${{ steps.get-release-name.outputs.name }}","python-version":"3.9"}')
matrixElements+=('{"os":"macos-11","variant":"mapping-tools","tag":"${{ steps.get-tag.outputs.tag }}","release-name":"${{ steps.get-release-name.outputs.name }}","python-version":"3.9"}')
fi
if [ "${#matrixElements[@]}" -eq "0" ]; then
echo run-installer=false >> $GITHUB_OUTPUT
else
echo run-installer=true >> $GITHUB_OUTPUT
fi
content=`join_by , ${matrixElements[@]}`
echo "{\"include\":[$content]}"
echo "matrix={\"include\":[$content]}" >> $GITHUB_OUTPUT
installer:
needs: setup
name: installer
if: needs.setup.outputs.run-installer == 'true'
runs-on: ${{ matrix.os }}
strategy:
matrix: ${{fromJson(needs.setup.outputs.matrix)}}
steps:
- name: Install create-dmg
if: runner.os == 'macOS'
shell: bash
run: brew install create-dmg
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Setup scripts
uses: actions/checkout@v3
with:
repository: hsorby/mapclientreleasescripts
path: scripts
ref: v0.19.0
- name: Create installer asset
id: create-installer
shell: bash
run: |
echo "Creating installer asset"
python -m venv venv
if [ "$RUNNER_OS" == "macOS" ]; then
python_exe=$GITHUB_WORKSPACE/venv/bin/python
pip_exe=$GITHUB_WORKSPACE/venv/bin/pip
# source venv/bin/activate
elif [ "$RUNNER_OS" == "Windows" ]; then
python_exe=$GITHUB_WORKSPACE/venv/Scripts/python.exe
pip_exe=$GITHUB_WORKSPACE/venv/Scripts/pip.exe
# source venv/Scripts/activate
else
echo "$RUNNER_OS not supported"
exit 1
fi
cd $GITHUB_WORKSPACE
cd scripts
# ${{ steps.get_tag.outputs.tag }}
# Manually install PyInstaller rather than use the dev install requires from setup.py.
$pip_exe install pyinstaller
if [ "${{ matrix.variant }}" == "mapclient" ]; then
$python_exe prepare_mapclient_release.py ${{ matrix.tag }}
variant=
elif [ "${{ matrix.variant }}" == "mapping-tools" ]; then
$python_exe prepare_mapclient_release.py ${{ matrix.tag }} -v mapping-tools -p plugin_listing.txt -w workflow_listing.txt
variant="-${{ matrix.variant }}"
else
echo "Variant not supported"
exit 2
fi
if [ "$RUNNER_OS" == "macOS" ]; then
#echo "Have to find out how to modify a finder window in headless mode with AppleScript."
#echo "Asset not ready for $RUNNER_OS"
asset=$GITHUB_WORKSPACE/scripts/mapclient/res/macos/MAP-Client${variant}-${{ matrix.release-name }}.dmg
echo $asset
echo "file=$asset" >> $GITHUB_OUTPUT
elif [ "$RUNNER_OS" == "Windows" ]; then
ls -lh mapclient/package
asset=$GITHUB_WORKSPACE/scripts/mapclient/package/MAP-Client${variant}-${{ matrix.release-name }}.exe
# asset=`ls -1 "$GITHUB_WORKSPACE"/mapclient/package/MAP-Client*.exe`
asset=${asset//\\//}
echo $asset
echo "file=$asset" >> $GITHUB_OUTPUT
else
echo "$RUNNER_OS not supported"
exit 1
fi
# echo $asset
echo "Upload it ..."
- name: Define asset
id: define-asset
if: false
shell: cmake -P {0}
run: |
set(ASSET_PATH "${{ steps.create-installer.outputs.file }}")
file(TO_NATIVE_PATH "${ASSET_PATH}" _NATIVE_PATH)
message(STATUS "file: ${_NATIVE_PATH}")
file(APPEND $ENV{GITHUB_OUTPUT} "file=${_NATIVE_PATH}")
- name: Upload asset
uses: softprops/action-gh-release@v1
with:
files: ${{ steps.create-installer.outputs.file }}
tag_name: ${{ matrix.tag }}