-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (113 loc) · 3.64 KB
/
Copy pathCICD.yml
File metadata and controls
117 lines (113 loc) · 3.64 KB
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
name: CICD
on:
push:
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
# - name: Test
# run: |
# pip install -r requirements.txt
# pip install pytest
# pytest
release:
runs-on: ubuntu-latest
needs: [test]
steps:
- name: Create Release
uses: actions/github-script@v7
with:
script: |
const refs = await github.rest.git.listMatchingRefs({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "tags/${{ github.head_ref }}-tag"
})
console.log(refs)
if(refs.data.length > 0) {
console.log("Tag already exists, skipping release")
return
}
github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: "${{ github.head_ref }}-tag",
name: "${{ github.head_ref }}",
prerelease: true,
target_commitish: "${{ github.head_ref }}"
})
env:
GH_TOKEN: ${{ github.token }}
build:
runs-on: ubuntu-latest
needs: release
# if: github.ref == 'refs/heads/next' || github.ref == 'refs/heads/master'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.TOKEN }}
- uses: actions/setup-python@v5
with:
python-version: "3.12"
# - name: Python Semantic Release
# uses: python-semantic-release/python-semantic-release@master
# id: semantic-release
# with:
# github_token: ${{ secrets.TOKEN }}
- name: Build
run: |
python3 -m pip install --upgrade build
python3 -m build
- name: Upload GH
run: |
git config --global --add safe.directory $GITHUB_WORKSPACE
files="dist/*.whl"
for file in $files
do
echo $file
counter=0
for i in 1 2 3 4 5; do gh release upload --clobber --repo $GITHUB_REPOSITORY ${{ github.head_ref }}-tag $file && break || counter=$[$counter +1] && sleep 30; done
echo $counter
if [ "$counter" -eq "5" ]; then exit 1; fi
done
env:
GITHUB_TOKEN: ${{ github.token }}
# - name: Upload PYPI
# if: steps.semantic-release.outputs.released == 'true'
# run: |
# python3 -m pip install twine==6.0.1
# python3 -m twine upload --repository pypi dist/* -u __token__ -p ${{ secrets.PYPI_TOKEN }}
# - name: Setup NODE
# uses: actions/setup-node@v3
# with:
# registry-url: "https://registry.npmjs.org"
# node-version: "20.x"
# - name: Upload NPM
# if: steps.semantic-release.outputs.released == 'true'
# run: |
# pwd
# cd ${{ github.workspace }}
# npm i
# npm run json
# jq '.version="${{steps.semantic-release.outputs.version}}"' package.json > temp && mv temp package.json
# cat package.json
# npm publish
# env:
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# - name: Merge master -> next
# if: github.ref == 'refs/heads/master'
# uses: devmasx/merge-branch@master
# with:
# type: now
# from_branch: master
# target_branch: next
# github_token: ${{ secrets.TOKEN }}