Skip to content

Commit 34311fb

Browse files
committed
Github action
1 parent c5549fd commit 34311fb

File tree

3 files changed

+77
-2
lines changed

3 files changed

+77
-2
lines changed

Diff for: .github/workflows/publish.yml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- '[0-9]+.[0-9]+.[0-9]+' # Matches semantic versioning tags
7+
- '[0-9]+.[0-9]+.[0-9]+-test.*' # Test releases
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ['3.12']
15+
16+
steps:
17+
- uses: actions/checkout@v3
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install dependencies and run CI
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install build pytest pytest-cov setuptools_scm
28+
make ci
29+
30+
publish:
31+
needs: test
32+
runs-on: ubuntu-latest
33+
permissions:
34+
contents: write
35+
steps:
36+
- uses: actions/checkout@v3
37+
38+
- name: Set up Python
39+
uses: actions/setup-python@v4
40+
with:
41+
python-version: '3.12'
42+
43+
- name: Verify tag version matches package version
44+
run: |
45+
python -m pip install --upgrade pip
46+
pip install build pytest pytest-cov setuptools_scm twine
47+
PACKAGE_VERSION=$(python -m setuptools_scm)
48+
TAG_VERSION=${GITHUB_REF#refs/tags/} # Remove 'refs/tags/' prefix
49+
if [ "$PACKAGE_VERSION" != "$TAG_VERSION" ]; then
50+
echo "Package version ($PACKAGE_VERSION) does not match tag version ($TAG_VERSION)"
51+
exit 1
52+
fi
53+
54+
- name: Publish to TestPyPI
55+
if: contains(github.ref, 'test')
56+
env:
57+
TWINE_USERNAME: __token__
58+
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
59+
run: make all && twine upload --repository testpypi dist/*
60+
61+
- name: Publish to PyPI
62+
if: "!contains(github.ref, 'test')"
63+
env:
64+
TWINE_USERNAME: __token__
65+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
66+
run: make dist
67+
68+
- name: Create Release
69+
uses: softprops/action-gh-release@v1
70+
with:
71+
files: dist/*
72+
generate_release_notes: true
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Diff for: Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.PHONY: all dist d clean c version v install i test t build b
22

3-
all: clean install test build version
3+
ci: clean install test
4+
all: ci build version
45

56
dist d: all
67
scripts/check-version.sh

Diff for: pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ classifiers = [
2222
]
2323
keywords = ["cedarscript", "code-editing", "refactoring", "code-analysis", "sql-like", "ai-assisted-development"]
2424
dependencies = [
25-
"cedarscript-ast-parser>=0.5.4",
25+
"cedarscript-ast-parser>=0.5.6",
2626
"grep-ast==0.3.3",
2727
# https://github.com/tree-sitter/py-tree-sitter/issues/303
2828
# https://github.com/grantjenks/py-tree-sitter-languages/issues/64

0 commit comments

Comments
 (0)