-
Notifications
You must be signed in to change notification settings - Fork 1
97 lines (79 loc) · 2.9 KB
/
publish-on-tag.yml
File metadata and controls
97 lines (79 loc) · 2.9 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
name: Publish on Tag
# Only runs when you create a tag like v1.2.3
on:
push:
tags:
- 'v*.*.*'
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Get version from tag
id: get_version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Publishing version: $VERSION"
- name: Verify version matches files
run: |
TAG_VERSION="${{ steps.get_version.outputs.version }}"
PYPROJECT_VERSION=$(python -c "import tomllib; f = open('pyproject.toml', 'rb'); data = tomllib.load(f); print(data['project']['version'])")
PACKAGE_VERSION=$(node -p "require('./package.json').version")
echo "Tag version: $TAG_VERSION"
echo "pyproject.toml version: $PYPROJECT_VERSION"
echo "package.json version: $PACKAGE_VERSION"
if [ "$TAG_VERSION" != "$PYPROJECT_VERSION" ] || [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
echo "❌ Version mismatch!"
echo "Please ensure all versions match before tagging:"
echo " - Tag: v$TAG_VERSION"
echo " - pyproject.toml: $PYPROJECT_VERSION"
echo " - package.json: $PACKAGE_VERSION"
exit 1
fi
echo "✅ All versions match!"
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build Python package
run: python -m build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.get_version.outputs.version }}
release_name: Release v${{ steps.get_version.outputs.version }}
body: |
## Installation
```bash
# npm
npm install -g git-quick-cli@${{ steps.get_version.outputs.version }}
# pip
pip install git-quick==${{ steps.get_version.outputs.version }}
```
See [CHANGELOG](https://github.com/${{ github.repository }}/compare/v${{ steps.get_version.outputs.version }}...main) for details.
draft: false
prerelease: false