From 3d0f72d7a5d47cfa03d48a76ebe9f4be36fa83a1 Mon Sep 17 00:00:00 2001 From: Todd OST Date: Thu, 25 Apr 2024 13:39:03 +0100 Subject: [PATCH 1/7] SYS: Add action to publish --- .github/workflows/pypi.yaml | 56 +++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/pypi.yaml diff --git a/.github/workflows/pypi.yaml b/.github/workflows/pypi.yaml new file mode 100644 index 0000000..3414c82 --- /dev/null +++ b/.github/workflows/pypi.yaml @@ -0,0 +1,56 @@ +name: Publish package + +on: + workflow_dispatch: + push: + tags: + - '*' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + + - name: Setup Python + uses: actions/setup-python@v3 + with: + python-version: '3.10' + + - name: Install packages + run: | + python -m pip install build twine + + - name: Build + run: | + python -m build + + - name: Check version + id: version + uses: jannekem/run-python-script-action@v1 + with: + script: | + from os import environ + + # get version from tag + tag_version_full = environ["GITHUB_REF"] + # extract version itself + tag_version = tag_version_full.split("/")[-1] + + if tag_version == "release": + # if tag version ends with release, this was run from a button - redirect to testpypi + with open(environ["GITHUB_OUTPUT"], "a") as f: + print("target=testpypi", file=f) + else: + # anything else, this was run from a release - target pypi proper + with open(environ["GITHUB_OUTPUT"], "a") as f: + print("target=pypi", file=f) + + - name: Upload to TestPyPi + if: endsWith(github.ref, 'release') + run: | + twine upload dist/* --repository testpypi -u __token__ -p ${{ secrets.TESTPYPI_API_TOKEN }} + - name: Upload to PyPi + if: endsWith(github.ref, 'release') == false + run: | + twine upload dist/* --repository pypi -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file From a29b1517d868271b6f63a2a19758bbfc7c50cb2d Mon Sep 17 00:00:00 2001 From: Todd OST Date: Thu, 25 Apr 2024 13:41:21 +0100 Subject: [PATCH 2/7] SYS: Try to echo github ref to see why if is triggering wrong --- .github/workflows/pypi.yaml | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/.github/workflows/pypi.yaml b/.github/workflows/pypi.yaml index 3414c82..d8a2bc7 100644 --- a/.github/workflows/pypi.yaml +++ b/.github/workflows/pypi.yaml @@ -25,32 +25,13 @@ jobs: run: | python -m build - - name: Check version - id: version - uses: jannekem/run-python-script-action@v1 - with: - script: | - from os import environ - - # get version from tag - tag_version_full = environ["GITHUB_REF"] - # extract version itself - tag_version = tag_version_full.split("/")[-1] - - if tag_version == "release": - # if tag version ends with release, this was run from a button - redirect to testpypi - with open(environ["GITHUB_OUTPUT"], "a") as f: - print("target=testpypi", file=f) - else: - # anything else, this was run from a release - target pypi proper - with open(environ["GITHUB_OUTPUT"], "a") as f: - print("target=pypi", file=f) - - name: Upload to TestPyPi if: endsWith(github.ref, 'release') run: | + echo ${{github.ref}} twine upload dist/* --repository testpypi -u __token__ -p ${{ secrets.TESTPYPI_API_TOKEN }} - name: Upload to PyPi if: endsWith(github.ref, 'release') == false run: | + echo ${{github.ref}} twine upload dist/* --repository pypi -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file From f5dd28beb70100bde5b4d6e6c8c0d99ae5ec9a03 Mon Sep 17 00:00:00 2001 From: Todd OST Date: Thu, 25 Apr 2024 13:43:40 +0100 Subject: [PATCH 3/7] SYS: Push to PyPi proper only on tagged commits --- .github/workflows/pypi.yaml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pypi.yaml b/.github/workflows/pypi.yaml index d8a2bc7..e7066b0 100644 --- a/.github/workflows/pypi.yaml +++ b/.github/workflows/pypi.yaml @@ -25,13 +25,11 @@ jobs: run: | python -m build - - name: Upload to TestPyPi - if: endsWith(github.ref, 'release') - run: | - echo ${{github.ref}} - twine upload dist/* --repository testpypi -u __token__ -p ${{ secrets.TESTPYPI_API_TOKEN }} - name: Upload to PyPi - if: endsWith(github.ref, 'release') == false + if: startsWith(github.ref, 'refs/tags/') + run: | + twine upload dist/* --repository pypi -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} + + - name: Upload to TestPyPi run: | - echo ${{github.ref}} - twine upload dist/* --repository pypi -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file + twine upload dist/* --repository testpypi -u __token__ -p ${{ secrets.TESTPYPI_API_TOKEN }} \ No newline at end of file From 1bdb87312af48a022abe7b1d87d987bd22cc6850 Mon Sep 17 00:00:00 2001 From: Todd OST Date: Thu, 25 Apr 2024 13:45:59 +0100 Subject: [PATCH 4/7] SYS: PyPi doesn't allow direct dependencies --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2b797b0..01e2c8f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,7 @@ docs = [ ] # dependencies for running the test suite tests = [ - "psychopy @ git+https://github.com/psychopy/psychopy@release", + "psychopy", "pytest", ] From a4d85645905c1c4217f37d312b093e72ca17dc28 Mon Sep 17 00:00:00 2001 From: Todd OST Date: Thu, 25 Apr 2024 13:46:37 +0100 Subject: [PATCH 5/7] SYS: Add template dependencies --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 01e2c8f..812e7e1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,6 +11,8 @@ authors = [ ] # a license tells other people how to use your code and protects you from stealing license = { text = "MIT" } +# add any packages which your plugin needs in order to run +dependencies = [] [project.urls] # some handy links to help people find your plugin's documentation From 8e4a807c73cc374c65fd8b42eb3e61d121f7fc8a Mon Sep 17 00:00:00 2001 From: Todd OST Date: Thu, 25 Apr 2024 13:48:39 +0100 Subject: [PATCH 6/7] SYS: Run PyPi publish on all pushes, as untagged ones will go to testpypi --- .github/workflows/pypi.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/pypi.yaml b/.github/workflows/pypi.yaml index e7066b0..9684b60 100644 --- a/.github/workflows/pypi.yaml +++ b/.github/workflows/pypi.yaml @@ -3,8 +3,6 @@ name: Publish package on: workflow_dispatch: push: - tags: - - '*' jobs: build: From fd30fc96c268b3ceb9426934179c234b6b10c07c Mon Sep 17 00:00:00 2001 From: Todd OST Date: Thu, 25 Apr 2024 13:51:22 +0100 Subject: [PATCH 7/7] SYS: Rollback previous commit - committing same version twice fails --- .github/workflows/pypi.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pypi.yaml b/.github/workflows/pypi.yaml index 9684b60..e7066b0 100644 --- a/.github/workflows/pypi.yaml +++ b/.github/workflows/pypi.yaml @@ -3,6 +3,8 @@ name: Publish package on: workflow_dispatch: push: + tags: + - '*' jobs: build: