-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (78 loc) · 2.73 KB
/
package-publishing.yml
File metadata and controls
84 lines (78 loc) · 2.73 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
name: Package Publishing
on:
push:
tags:
- 'node-v*.*.*'
- 'python-v*.*.*'
- 'dotnet-v*.*.*'
jobs:
determine-sdk:
runs-on: ubuntu-latest
outputs:
sdk_type: ${{ steps.extract.outputs.sdk_type }}
version: ${{ steps.extract.outputs.version }}
steps:
- id: extract
run: |
TAG=${GITHUB_REF#refs/tags/}
SDK_TYPE=${TAG%-v*}
VERSION=${TAG#*-v}
echo "sdk_type=$SDK_TYPE" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
publish-package:
needs: determine-sdk
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Node.js publishing
- name: Setup Node.js
if: ${{ needs.determine-sdk.outputs.sdk_type == 'node' }}
uses: actions/setup-node@v3
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- name: Publish Node package
if: ${{ needs.determine-sdk.outputs.sdk_type == 'node' }}
run: |
cd sdk/node
npm ci
npm run build
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
HPKV_API_BASE_URL: ${{ secrets.HPKV_API_BASE_URL }}
HPKV_API_KEY: ${{ secrets.HPKV_API_KEY }}
# Python publishing
- name: Setup Python
if: ${{ needs.determine-sdk.outputs.sdk_type == 'python' }}
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Publish Python package
if: ${{ needs.determine-sdk.outputs.sdk_type == 'python' }}
run: |
cd sdk/python
# Update version in setup.py or pyproject.toml
sed -i "s/version=\".*\"/version=\"${{ needs.determine-sdk.outputs.version }}\"/g" setup.py
pip install build twine
python -m build
python -m twine upload dist/*
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
# .NET publishing
- name: Setup .NET
if: ${{ needs.determine-sdk.outputs.sdk_type == 'dotnet' }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'
- name: Publish .NET package
if: ${{ needs.determine-sdk.outputs.sdk_type == 'dotnet' }}
run: |
cd sdk/dotnet
# Update version in .csproj
sed -i "s/<Version>.*<\/Version>/<Version>${{ needs.determine-sdk.outputs.version }}<\/Version>/g" **/*.csproj
dotnet restore
dotnet build -c Release
dotnet pack -c Release
dotnet nuget push **/bin/Release/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json