-
Notifications
You must be signed in to change notification settings - Fork 6
115 lines (100 loc) · 4.64 KB
/
publish_python.yml
File metadata and controls
115 lines (100 loc) · 4.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
name: publish_python_package
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
ref: main
- name: Set up Python 3.11
uses: actions/setup-python@v1
with:
python-version: 3.11
- uses: actions/setup-node@v1
with:
node-version: 18.x
registry-url: https://registry.npmjs.org/
scope: '@codytodonnell'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Install dependencies
run: |
sudo apt-get update
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install twine
npm install --legacy-peer-deps
- name: Sync version from Git Tag
run: |
npm version ${{ github.ref_name }} --no-git-tag-version
- name: Build tarball
run: |
npm run build
python setup.py sdist
- name: Publish package to NPM
run: |
VERSION=$(node -p "require('./package.json').version")
if [[ "$VERSION" == *"-rc"* ]]; then
npm publish --tag rc
else
npm publish
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish a Python distribution to test PyPI
env:
PI_PY_SECRET: ${{ secrets.PYPI_TOKEN }}
PI_PY_USERTOKEN: __token__
run: |
echo Publishing to test repo $PI_PY_USERTOKEN
twine upload dist/* -u $PI_PY_USERTOKEN -p $PI_PY_SECRET
- name: make new branch
run: |
git config --global user.name github-actions
git config --global user.email github-actions@github.com
git checkout -B auto-build-and-sync-styles
- name: detect auto-build-and-sync-styles branches
id: upgrade_changes
run: echo "count=$(git branch -r | grep auto-build-and-sync-styles- | wc -l | xargs)" >> $GITHUB_OUTPUT
- name: merge all auto-build-and-sync-styles branches
if: ${{ fromJSON(steps.upgrade_changes.outputs.count) > 0 }}
run: |
git branch -r | grep auto-build-and-sync-styles- | xargs -I {} git merge {}
git rebase ${GITHUB_REF##*/}
git reset $(git merge-base ${GITHUB_REF##*/} HEAD)
git commit -a -m "auto build and sync styles "
git push -f origin auto-build-and-sync-styles
git branch -r | grep auto-build-and-sync-styles- | cut -d/ -f2 | xargs -I {} git push origin :{}
- name: Detect changes
id: changes
shell: bash
run: |
git add -f dash_mp_components/ ':!dash_mp_components/__pycache__/**'
echo "count=`git diff --cached --quiet --ignore-submodules -- . ':!docker/python'; echo $?`" >> $GITHUB_OUTPUT
echo "files=$(git ls-files --exclude-standard --others | wc -l | xargs)" >> $GITHUB_OUTPUT
- name: commit & push changes
if: ${{ fromJSON(steps.changes.outputs.count) > 0 || fromJSON(steps.changes.outputs.files) > 0 }}
shell: bash
run: |
git add -A
git commit --allow-empty -m "auto build and sync styles "
git push -f origin auto-build-and-sync-styles
- name: Open pull request if needed
if: ${{ fromJSON(steps.changes.outputs.count) > 0 || fromJSON(steps.changes.outputs.files) > 0 }}
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
# Only open a PR if the branch is not attached to an existing one
run: |
PR=$(gh pr list --head auto-build-and-sync-styles --json number -q '.[0].number')
if [ -z $PR ]; then
gh pr create \
--head auto-build-and-sync-styles \
--title "Automated build and sync styles" \
--body "Full log: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
else
echo "Pull request already exists, won't create a new one."
fi