From e47aa0bb77b8a4d41051664f982cf4b40055b864 Mon Sep 17 00:00:00 2001 From: KeshavAnandCode Date: Tue, 19 May 2026 15:43:01 -0500 Subject: [PATCH] added workflows again --- .gitea/workflows/ci.yml | 29 ++++++++++++++ .gitea/workflows/publish.yml | 78 ++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 .gitea/workflows/ci.yml create mode 100644 .gitea/workflows/publish.yml diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..d32a8e9 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,29 @@ +name: CI + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install Core with Dev Dependencies + run: | + pip install --upgrade pip + pip install -e .[dev] + + - name: Run Quality Checks (Linter) + run: ruff check src/ + + - name: Execute Test Suite + run: pytest tests/ -v diff --git a/.gitea/workflows/publish.yml b/.gitea/workflows/publish.yml new file mode 100644 index 0000000..5c11d44 --- /dev/null +++ b/.gitea/workflows/publish.yml @@ -0,0 +1,78 @@ +name: Publish Core + +on: + push: + tags: + - "v*" # Fires directly on v0.1.0, v0.2.0 etc. + +jobs: + # Enforce that tests MUST pass before release can execute + verify: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + - name: Install and Verify + run: | + pip install -e .[dev] + pytest tests/ -v + + publish: + needs: verify # Blocks execution if verify job fails + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install Release Tools + run: pip install build twine + + - name: Build Wheel and Source Distribution + run: python -m build . + + - name: Publish Package to PyPI + env: + TWINE_USERNAME: __token__ + # Inherits your clean Organization level secret + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + run: twine upload --skip-existing dist/* + + - name: Build Gitea Release with Assets + env: + # Pulls your clean Organization level Gitea Token + GIT_RELEASE_TOKEN: ${{ secrets.GIT_RELEASE_TOKEN }} + run: | + TAG=${GITHUB_REF#refs/tags/} + + # Delete existing release block if present + EXISTING=$(curl -s -H "Authorization: token $GIT_RELEASE_TOKEN" "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/tags/$TAG") + EXISTING_ID=$(echo $EXISTING | python -c "import sys,json; d=json.load(sys.stdin); print(d.get('id',''))" 2>/dev/null || echo "") + if [ -n "$EXISTING_ID" ]; then + curl -s -X DELETE -H "Authorization: token $GIT_RELEASE_TOKEN" "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/$EXISTING_ID" + fi + + # Create fresh production release container + RELEASE=$(curl -s -X POST \ + -H "Authorization: token $GIT_RELEASE_TOKEN" \ + -H "Content-Type: application/json" \ + -d "{ + \"tag_name\": \"$TAG\", + \"name\": \"foreignthon $TAG\", + \"body\": \"Release version $TAG of foreignthon core compiler engine.\", + \"draft\": false, + \"prerelease\": false + }" "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases") + + RELEASE_ID=$(echo $RELEASE | python -c "import sys,json; print(json.load(sys.stdin)['id'])") + + # Upload wheels directly into Gitea Assets tab + for FILE in dist/*; do + curl -s -X POST -H "Authorization: token $GIT_RELEASE_TOKEN" -F "attachment=@$FILE" "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/$RELEASE_ID/assets" + done