-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (120 loc) · 4.04 KB
/
Copy pathdeploy.yaml
File metadata and controls
130 lines (120 loc) · 4.04 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
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Deploy
on:
push:
branches: [prd, dev]
paths-ignore: # Pushes that include only these changed files won't trigger
- "**/.gitignore"
- "**/tests/*"
- "**/_version.py"
jobs:
update-version:
name: Update Version
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Update Version
uses: byuawsfhtl/UpdateVersion@v1.0.9
with:
token: ${{ secrets.RLL_BOT_PA_TOKEN }}
versionPath: ${{ github.workspace }}/_version.py
build-python:
name: Build Python distribution 📦
if: github.ref == 'refs/heads/prd' # Only publish when pushing to prd
needs: update-version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }} # Explicitly checkout the branch that triggered the workflow
# This ensures we're using the latest commit including version updates
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install pypa/build
run: python3 -m pip install build
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
publish-to-pypi:
name: Publish Python 🐍 distribution 📦 to PyPI
if: github.ref == 'refs/heads/prd' # Only publish when pushing to prd
needs: build-python
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/PyScriptTestUtils
permissions:
id-token: write
steps:
- uses: actions/checkout@v4 # Needed to ensure repo context
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Verify dist exists
run: ls -l dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_ACCESS_TOKEN }}
build-typescript:
name: Build TypeScript distribution 📦
if: github.ref == 'refs/heads/prd' # Only publish when pushing to prd
needs: update-version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm ci
- name: Sync version from _version.py to package.json
run: |
VERSION=$(python3 -c "exec(open('_version.py').read()); print(__version__)")
npm version "$VERSION" --no-git-tag-version --allow-same-version
- name: Build TypeScript
run: npm run build
- name: Store the TypeScript distribution
uses: actions/upload-artifact@v4
with:
name: typescript-package-distributions
path: |
dist
package.json
package-lock.json
README.md
publish-to-npm:
name: Publish TypeScript 📘 distribution 📦 to npm
if: github.ref == 'refs/heads/prd' # Only publish when pushing to prd
needs: build-typescript
runs-on: ubuntu-latest
steps:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- name: Download TypeScript distribution
uses: actions/download-artifact@v4
with:
name: typescript-package-distributions
path: npm-publish
- name: Verify package layout
working-directory: npm-publish
run: ls -la && ls -l dist/
- name: Publish to npm
working-directory: npm-publish
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # Token will expire every 90 days. Will have to update this token periodically.