-
Notifications
You must be signed in to change notification settings - Fork 14
148 lines (137 loc) · 5.69 KB
/
uploadrelease.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
name: upload-release
# This builds, packages and releases pygluu-kubernetes
on:
push:
tags:
- '*'
workflow_dispatch:
inputs:
nightly:
description: 'Enable nightly build'
default: "false"
required: false
schedule:
- cron: "0 0 * * *"
jobs:
publish:
name: Publish for ${{ matrix.asset_name }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
# flex linux setup
- os: ubuntu-latest
artifact_name: flex-linux-setup.pyz
asset_name: flex-linux-setup-ubuntu-amd64.pyz
asset_directory: flex-linux-setup
python_version: 3.8
# flex linux setup on CentOS8
- os: ubuntu-latest
artifact_name: flex-linux-setup.pyz
asset_name: flex-linux-setup-centos-amd64.pyz
asset_directory: flex-linux-setup
python_version: 3.8
# helm chart
- os: ubuntu-latest
artifact_name: helm # Will be changed automatically
asset_name: helm # Will be changed automatically
asset_directory: charts/gluu
python_version: 3.8
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Build Helm Package
if: matrix.asset_name == 'helm'
run: |
cd ${{ matrix.asset_directory }}
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
helm package .
ASSET_NAME=$(ls ${{github.workspace}}/${{ matrix.asset_directory }} | grep ".tgz" | grep -Ev "sha256sum" | sort -rn | head -1)
sha256sum ${ASSET_NAME} > ${ASSET_NAME}.sha256sum
- name: Map outputs
id: output
run: |
if [[ "${{ matrix.asset_name }}" == "helm" ]]; then
ASSET_NAME=$(ls ${{github.workspace}}/${{ matrix.asset_directory }} | grep ".tgz" | grep -Ev "sha256sum" | sort -rn | head -1)
echo "Modifying helm asset name to ${ASSET_NAME}"
echo "artifact_name=${ASSET_NAME}" >> $GITHUB_OUTPUT
echo "asset_name=${ASSET_NAME}" >> $GITHUB_OUTPUT
else
echo "artifact_name=${{ matrix.artifact_name }}" >> $GITHUB_OUTPUT
echo "asset_name=${{ matrix.asset_name }}" >> $GITHUB_OUTPUT
fi
echo "tag=$(curl https://api.github.com/repos/${{ github.repository }}/releases -s | grep "tag_name" | cut -d '"' -f 4 | grep -o '^\v.*' | head -n 1)" >> $GITHUB_OUTPUT
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
pip3 install jq
- name: Lint with flake8
run: |
pip3 install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --exit-zero --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Build Zipapp
if: matrix.asset_name != 'flex-linux-setup-centos8-amd64.pyz' && matrix.asset_name != 'helm'
run: |
sudo apt-get update || brew install jq
sudo apt-get install build-essential || echo "Maybe im on macos OS"
pip3 install shiv
cd ${{ matrix.asset_directory }}
make zipapp
sha256sum ${{ steps.output.outputs.artifact_name }} > ${{ steps.output.outputs.artifact_name }}.sha256sum
ls
- uses: addnab/docker-run-action@v3
if: matrix.asset_name == 'flex-linux-setup-centos8-amd64.pyz'
name: Build with CentOS8
continue-on-error: true
with:
image: centos/python-36-centos7:latest
options: -v ${{ github.workspace }}:/centos
run: |
echo "Building flex-linux-setup package"
cd /centos/flex-linux-setup
pip install shiv
make zipapp
sha256sum ${{ steps.output.outputs.artifact_name }} > ${{ steps.output.outputs.artifact_name }}.sha256sum
ls
- name: Get latest tag
id: previoustag
run: |
echo "tag=$(curl https://api.github.com/repos/${{ github.repository }}/releases -s | grep "tag_name" | cut -d '"' -f 4 | grep -o '^\v.*' | head -n 1)" >> $GITHUB_OUTPUT
- name: Print outputs
run: |
echo "ASSETNAME=${{ steps.output.outputs.asset_name }}" >> ${GITHUB_ENV}
#If on schedule build nightly packages
if [ ${{ github.event_name }} = "schedule" ] || [ ${{ github.event.inputs.nightly }} = true ]; then
echo "Activating nightly build"
echo "ASSETNAME=nightly-build-${{ steps.output.outputs.asset_name }}" >> ${GITHUB_ENV}
fi
echo "${{ steps.previoustag.outputs.tag }}"
echo "$ASSETNAME"
echo "${{ steps.output.outputs.artifact_name }}"
- name: Upload binaries to release
continue-on-error: true
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.MOWORKFLOWTOKEN }}
file: ${{github.workspace}}/${{ matrix.asset_directory }}/${{ steps.output.outputs.artifact_name }}
asset_name: ${{ env.ASSETNAME }}
tag: ${{ steps.previoustag.outputs.tag }}
overwrite: true
- name: Upload shas to release
continue-on-error: true
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.MOWORKFLOWTOKEN }}
file: ${{github.workspace}}/${{ matrix.asset_directory }}/${{ steps.output.outputs.artifact_name }}.sha256sum
asset_name: ${{ env.ASSETNAME }}.sha256sum
tag: ${{ steps.previoustag.outputs.tag }}
overwrite: true