-
Notifications
You must be signed in to change notification settings - Fork 2
199 lines (197 loc) · 6.06 KB
/
shells-ci.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
name: CI
on:
push:
paths-ignore:
- "README.md"
- "docs/readme.md"
pull_request:
paths-ignore:
- "README.md"
- "docs/readme.md"
release:
types: [published]
jobs:
pre-commit:
name: Run pre-commit
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install pip -U
pip install tox
- name: Run pre-commit
env:
TOXENV: pre-commit
run: tox
pack:
name: Pack the Shell
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install pip -U
pip install tox
- name: Build
env:
TOXENV: pack
run: tox
download-linux-dependencies:
name: Download Linux dependencies
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.9"]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Download dependencies
run: |
python -m pip install pip -U
pip download -r src/requirements.txt -d dependencies
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: linux-dependencies
path: |
dependencies
download-windows-dependencies:
name: Download Windows dependencies
runs-on: windows-2019
strategy:
matrix:
python-version: ["3.7", "3.9"]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: "x86"
- name: Download dependencies
run: |
python -m pip install pip -U
pip download -r src/requirements.txt -d dependencies
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: windows-dependencies
path: |
dependencies
check-version:
name: Check version
# only for PRs in master
if: ${{ github.base_ref == 'master' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get current version
id: currentVersion
uses: mikefarah/yq@master
with:
cmd: yq e ".metadata.template_version" shell-definition.yaml
- name: Save shell-definition.yaml from master
run: |
git clone https://github.com/${{ github.repository }}.git ${{ github.repository }}
BASE_DIR=`pwd`
cd ${{ github.repository }}
git checkout -qf ${{ github.head_ref }}
git show master:shell-definition.yaml > $BASE_DIR/tmp.yaml
- name: Get master version
id: masterVersion
uses: mikefarah/yq@master
with:
cmd: yq e ".metadata.template_version" tmp.yaml
- name: Check version
run: |
! diff <(echo "${{ steps.currentVersion.outputs.result }}") <(echo "${{ steps.masterVersion.outputs.result }}")
check-not-shell-in-shell-name:
name: Check "Shell" is not in the Shell name
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: get Node Type
id: getNodeType
uses: mikefarah/yq@master
with:
cmd: yq e ".node_types | keys | .[0]" shell-definition.yaml
- name: Check shell is not in the Shell name
run: |
NODE_TYPE="${{ steps.getNodeType.outputs.result }}"
SHELL_NAME=`echo ${NODE_TYPE:16} | tr "[:upper:]" "[:lower:]"`
if [[ $SHELL_NAME == *" shell "* ]]
then
echo "You should remove 'Shell' from the Shell name"
exit 1
else
echo "not found"
fi
create-gh-release:
needs: [pre-commit, pack, download-linux-dependencies, download-windows-dependencies]
if: ${{ github.ref == 'refs/heads/master' && github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install dependencies
run: |
sudo apt-get -y install jq
python -m pip install pip -U
pip install tox yq
- name: Pack
env:
TOXENV: pack
run: tox
- name: Get Linux dependencies
uses: actions/download-artifact@v2
with:
name: linux-dependencies
path: linux-dependencies
- name: Get Windows dependencies
uses: actions/download-artifact@v2
with:
name: windows-dependencies
path: windows-dependencies
- name: Set envs
run: |
version="$(yq -r .metadata.template_version shell-definition.yaml)"
repo_owner=${{ github.repository }}
index=`expr index "$repo_owner" /`
repo=${repo_owner:index}
echo "TAG=$version" >> $GITHUB_ENV
echo "REPO=$repo" >> $GITHUB_ENV
- name: Pack dependencies
run: |
zip -j dist/cloudshell-$REPO-dependencies-win-package-$TAG.zip windows-dependencies/*
zip -j dist/cloudshell-$REPO-dependencies-linux-package-$TAG.zip linux-dependencies/*
- name: Create GitHub release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: "dist/*"
draft: true
name: ${{ env.REPO }} ${{ env.TAG }}
tag: ${{ env.TAG }}
commit: master