diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e5f6bb9..43130a9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -232,13 +232,12 @@ jobs: # chmod +x ./codexctl # ./codexctl download --hardware rm2 --out /tmp toltec release: - name: Release + name: ${{ github.ref == 'refs/heads/main' && 'Release' || 'Test release' }} needs: - remote - device #- test_device runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' permissions: contents: write steps: @@ -246,6 +245,18 @@ jobs: run: | echo "NAME=$(date +'%Y-%m-%d %H:%M')" >> $GITHUB_ENV echo "TAG=$(date +%s)" >> $GITHUB_ENV + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.13' + - name: Check out repository + uses: actions/checkout@v4 + - name: Install Poetry + run: | + sudo apt-get update + sudo apt-get install -y libfuse-dev pkg-config + curl -sSL https://install.python-poetry.org | python3 - + echo "$HOME/.local/bin" >> $GITHUB_PATH - uses: actions/download-artifact@v4 with: path: artifacts @@ -257,6 +268,7 @@ jobs: popd done - uses: ncipollo/release-action@v1 + if: github.ref == 'refs/heads/main' with: artifacts: "artifacts/*.zip" name: ${{ env.NAME }} @@ -264,3 +276,23 @@ jobs: commit: ${{ github.sha }} generateReleaseNotes: true makeLatest: true + - name: Update version + run: sed -i -E "s/^version = \"(.*)\"$/version = \"\1.post$tag\"/" pyproject.toml + env: + tag: ${{ env.TAG }} + - name: Install dependencies + run: poetry install --no-interaction + - name: Build package + run: poetry build + - name: Publish to pypi + if: github.ref == 'refs/heads/main' + run: poetry publish + env: + POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }} + - name: Test output + if: github.ref != 'refs/heads/main' + run: | + echo "name: ${{ env.NAME }}" + echo "tag: ${{ env.TAG }}" + echo "commit: ${{ github.sha }}" + echo "version: $(grep '^version = ' pyproject.toml | cut -d= -f2 | jq -r)" diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml deleted file mode 100644 index 9379f92..0000000 --- a/.github/workflows/python-publish.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Publish to PyPI - -on: - workflow_dispatch: - release: - types: [published] - -jobs: - publish: - runs-on: ubuntu-latest - steps: - - name: Check out repository - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.13' - - - name: Install Poetry - run: | - sudo apt-get update - sudo apt-get install libfuse-dev pkg-config - curl -sSL https://install.python-poetry.org | python3 - - echo "$HOME/.local/bin" >> $GITHUB_PATH - - - name: Install dependencies - run: poetry install --no-interaction - - - name: Build and Publish - env: - # Use a PyPI API Token for security - POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }} - run: poetry publish --build