-
Notifications
You must be signed in to change notification settings - Fork 0
168 lines (138 loc) · 5.38 KB
/
publish.yml
File metadata and controls
168 lines (138 loc) · 5.38 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
160
161
162
163
164
165
166
167
168
name: Publish Packages
on:
push:
branches: [ main ]
workflow_dispatch:
inputs:
version:
description: 'Version to publish (leave empty to use version.json)'
required: false
type: string
jobs:
read-version:
name: Read Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Get version from version.json
id: get-version
run: |
VERSION=$(jq -r '.library_version' version.json)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Publishing library version: $VERSION"
publish-nuget:
name: Publish to NuGet
needs: read-version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Restore dependencies
run: dotnet restore src/CSharp/DevPossible.Ton/DevPossible.Ton.csproj
- name: Build
run: dotnet build src/CSharp/DevPossible.Ton/DevPossible.Ton.csproj --configuration Release --no-restore
- name: Test
run: dotnet test src/CSharp/DevPossible.Ton.Tests/DevPossible.Ton.Tests.csproj --configuration Release --verbosity normal
- name: Pack
run: dotnet pack src/CSharp/DevPossible.Ton/DevPossible.Ton.csproj --configuration Release --no-build -p:PackageVersion=${{ needs.read-version.outputs.version }} --output .
- name: Publish to NuGet
run: dotnet nuget push DevPossible.Ton.*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
publish-npm:
name: Publish to npm
needs: read-version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- name: Verify package.json version
working-directory: src/JavaScript/devpossible-ton
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
TARGET_VERSION="${{ needs.read-version.outputs.version }}"
echo "package.json version: $CURRENT_VERSION"
echo "version.json version: $TARGET_VERSION"
if [ "$CURRENT_VERSION" != "$TARGET_VERSION" ]; then
echo "❌ Version mismatch detected!"
echo "This should not happen - version-check.yml should have caught this."
exit 1
fi
- name: Install dependencies
working-directory: src/JavaScript/devpossible-ton
run: npm ci
- name: Build
working-directory: src/JavaScript/devpossible-ton
run: npm run build
- name: Test
working-directory: src/JavaScript/devpossible-ton
run: npm test
- name: Publish to npm
working-directory: src/JavaScript/devpossible-ton
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-pypi:
name: Publish to PyPI
needs: read-version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Verify setup.py version
working-directory: src/Python/devpossible_ton
run: |
VERSION="${{ needs.read-version.outputs.version }}"
PYTHON_VERSION=$(echo $VERSION | sed 's/-alpha/a0/')
CURRENT_VERSION=$(grep 'version=' setup.py | sed -n 's/.*version="\([^"]*\)".*/\1/p')
echo "setup.py version: $CURRENT_VERSION"
echo "Expected version: $PYTHON_VERSION"
if [ "$CURRENT_VERSION" != "$PYTHON_VERSION" ]; then
echo "❌ Version mismatch detected!"
echo "This should not happen - version-check.yml should have caught this."
exit 1
fi
- name: Build package
working-directory: src/Python/devpossible_ton
run: python -m build
- name: Publish to PyPI
working-directory: src/Python/devpossible_ton
run: python -m twine upload dist/* --skip-existing
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
create-release:
name: Create GitHub Release
needs: [read-version, publish-nuget, publish-npm, publish-pypi]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.read-version.outputs.version }}
release_name: Release ${{ needs.read-version.outputs.version }}
body: |
Release ${{ needs.read-version.outputs.version }}
Published to:
- NuGet: https://www.nuget.org/packages/DevPossible.Ton/${{ needs.read-version.outputs.version }}
- npm: https://www.npmjs.com/package/@devpossible/ton/v/${{ needs.read-version.outputs.version }}
- PyPI: https://pypi.org/project/devpossible-ton/${{ needs.read-version.outputs.version }}/
draft: false
prerelease: ${{ contains(needs.read-version.outputs.version, 'alpha') || contains(needs.read-version.outputs.version, 'beta') }}