-
Notifications
You must be signed in to change notification settings - Fork 16
159 lines (154 loc) · 4.92 KB
/
Copy pathbuild.yml
File metadata and controls
159 lines (154 loc) · 4.92 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Build
on:
pull_request:
push:
branches:
- main
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+a[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+b[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+rc[0-9]+"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up pixi
uses: prefix-dev/setup-pixi@82d477f15f3a381dbcc8adc1206ce643fe110fb7 # v0.9.3
with:
environments: build
- name: Build project
run: pixi run -e build build-wheel
- name: Check package
run: pixi run -e build check-wheel
- name: Upload package
uses: actions/upload-artifact@v6
with:
name: pip
path: dist/*
- name: Upload bundle
uses: actions/upload-artifact@v6
with:
name: cdn
path: src/panel_material_ui/dist/
release:
name: Publish package
if: startsWith(github.ref, 'refs/tags/')
needs: [build]
runs-on: ubuntu-latest
permissions:
id-token: write
environment: pypi
steps:
- uses: actions/download-artifact@v7
with:
name: pip
path: dist/
- name: Publish package on PyPi
uses: pypa/gh-action-pypi-publish@release/v1
publish_cdn:
name: Publish to CDN
if: startsWith(github.ref, 'refs/tags/')
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v7
with:
name: cdn
path: dist/
- name: Get Tag Name
id: get_tag
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v5
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Upload to S3
run: aws s3 sync ./dist s3://cdn.holoviz.org/panel-material-ui/${{ env.TAG_NAME }}/
publish_npm:
name: Publish npm package
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
needs: [build]
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/download-artifact@v7
with:
name: cdn
path: dist/
- name: Derive npm package version
run: |
TAG_NAME="${GITHUB_REF#refs/tags/v}"
export TAG_NAME
python - <<'PY'
import os
import re
import sys
tag = os.environ["TAG_NAME"]
pattern = re.compile(r"^(\d+\.\d+\.\d+)(?:(a|b|rc)(\d+))?$")
match = pattern.match(tag)
if not match:
print(f"Unsupported release tag format: {tag}", file=sys.stderr)
sys.exit(1)
base, prerelease_label, prerelease_number = match.groups()
npm_version = base
npm_tag = "latest"
if prerelease_label:
label_map = {"a": "alpha", "b": "beta", "rc": "rc"}
npm_version = f"{base}-{label_map[prerelease_label]}.{prerelease_number}"
npm_tag = "next"
with open(os.environ["GITHUB_ENV"], "a", encoding="utf-8") as env:
env.write(f"NPM_VERSION={npm_version}\n")
env.write(f"NPM_TAG={npm_tag}\n")
PY
- name: Create npm package metadata
working-directory: dist
run: |
cat <<EOF > package.json
{
"name": "@holoviz/panel-material-ui",
"version": "${NPM_VERSION}",
"description": "Panel Material UI frontend bundle assets.",
"license": "BSD-3-Clause",
"homepage": "https://github.com/panel-extensions/panel-material-ui",
"repository": {
"type": "git",
"url": "https://github.com/panel-extensions/panel-material-ui.git"
},
"publishConfig": {
"access": "public"
},
"files": [
"*"
]
}
EOF
- name: Copy README and license
run: |
cp README.md dist/README.md
cp LICENSE.txt dist/LICENSE.txt
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: 24
registry-url: https://registry.npmjs.org
- name: npm dev deploy
if: contains(github.ref_name, 'a') || contains(github.ref_name, 'b') || contains(github.ref_name, 'rc')
working-directory: dist
run: |
npm publish --access public --tag dev --provenance
- name: npm main deploy
if: ${{ !contains(github.ref_name, 'a') && !contains(github.ref_name, 'b') && !contains(github.ref_name, 'rc') }}
working-directory: dist
run: |
npm publish --access public --tag latest --provenance