1
+ name : cicd
2
+
3
+ on : [push]
4
+
5
+ jobs :
6
+ build :
7
+ runs-on : ubuntu-20.04
8
+ strategy :
9
+ max-parallel : 1
10
+ matrix :
11
+ python-version : [3.9]
12
+
13
+ steps :
14
+ - name : Checkout source
15
+ uses : actions/checkout@v2
16
+ with :
17
+ ref : ${{ github.head_ref }}
18
+ submodules : recursive
19
+ - name : Set up Python ${{ matrix.python-version }}
20
+ uses : actions/setup-python@v2
21
+ with :
22
+ python-version : ${{ matrix.python-version }}
23
+ - name : Setup Go and protoc
24
+ run : |
25
+ python do.py setup_ext
26
+ - name : Install dependencies
27
+ run : |
28
+ python do.py setup
29
+ python do.py init
30
+ - name : Generate Python and Go SDK
31
+ run : |
32
+ ".env/bin/python" do.py generate_sdk
33
+ - name : Build distribution
34
+ run : |
35
+ python do.py dist
36
+ python do.py generate_distribution_checksum
37
+ - name : Commit go and python pkg
38
+ id : get_sha
39
+ run : |
40
+ git config user.name "Github Actions Bot"
41
+ git config user.email "[email protected] "
42
+ git pull
43
+ git add --force goopenl1s/\*
44
+ git add --force openl1s/\*
45
+ git add --force requirements.txt
46
+ if git status --porcelain | grep .
47
+ then
48
+ git commit -m "Update auto generated go openl1s"
49
+ git push
50
+ else
51
+ echo "No change in auto generated go openl1s"
52
+ fi
53
+ echo "::set-output name=sha::$(git rev-parse HEAD)"
54
+ - name : storing get_sha in file
55
+ run : |
56
+ echo "${{ steps.get_sha.outputs.sha }}" > store_sha_file
57
+ - name : Archive generated artifacts
58
+ uses : actions/upload-artifact@v2
59
+ with :
60
+ name : generated-artifacts
61
+ path : |
62
+ dist
63
+ openl1s
64
+ goopenl1s
65
+ testbed-models-release
66
+ *.proto
67
+ store_sha_file
68
+
69
+ publish_python_package :
70
+ if : github.ref == 'refs/heads/main'
71
+ needs : [build]
72
+ runs-on : ubuntu-20.04
73
+ steps :
74
+ - name : Checkout source
75
+ uses : actions/checkout@v2
76
+ with :
77
+ ref : ${{ github.head_ref }}
78
+ - name : Set up Python
79
+ uses : actions/setup-python@v2
80
+ with :
81
+ python-version : 3.6
82
+ - uses : actions/download-artifact@v2
83
+ with :
84
+ name : generated-artifacts
85
+ - name : Display structure of downloaded files
86
+ run : ls -R
87
+ - name : Get package version
88
+ id : get_version
89
+ run : |
90
+ echo "::set-output name=version::v$(python do.py version)"
91
+ - name : Check tag for current version
92
+
93
+ id : check_tag
94
+ with :
95
+ tag : ${{ steps.get_version.outputs.version }}
96
+ env :
97
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
98
+ - name : Publish package
99
+ if : github.ref == 'refs/heads/main' && steps.check_tag.outputs.exists == 'false'
100
+ run : |
101
+ PYPI_USERNAME=__token__ PYPI_PASSWORD=${{ secrets.PYPI_API_TOKEN }} python do.py release
102
+ - name : Create release and publish artifacts
103
+ if : github.ref == 'refs/heads/main' && steps.check_tag.outputs.exists == 'false'
104
+ uses : ncipollo/release-action@v1
105
+ with :
106
+ artifacts : " dist/*,testbed-models-release,*.proto"
107
+ tag : ${{ steps.get_version.outputs.version }}
108
+ token : ${{ secrets.GITHUB_TOKEN }}
109
+ - name : get_sha value from file
110
+ id : get_sha
111
+ run : |
112
+ echo "::set-output name=value::$(cat store_sha_file)"
113
+ - name : Create tag for goopentestbed
114
+ if : github.ref == 'refs/heads/main' && steps.check_tag.outputs.exists == 'false'
115
+ uses : actions/github-script@v3
116
+ with :
117
+ github-token : ${{ github.token }}
118
+ script : |
119
+ github.git.createRef({
120
+ owner: context.repo.owner,
121
+ repo: context.repo.repo,
122
+ ref: "refs/tags/goopentestbed/${{ steps.get_version.outputs.version }}",
123
+ sha: "${{ steps.get_sha.outputs.value }}"
124
+ })
0 commit comments