From a43768fc89c3cf3e1ab8a523d4bbcb98b1eff93d Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Mon, 24 Jul 2023 15:05:50 +0100 Subject: [PATCH 01/24] Deleted CodeQL because it's not properly supported anymore --- .github/workflows/codeql-analysis.yml | 71 --------------------------- 1 file changed, 71 deletions(-) delete mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index b5846fc..0000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,71 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -name: "CodeQL" - -on: - push: - branches: [master] - pull_request: - # The branches below must be a subset of the branches above - branches: [master] - schedule: - - cron: '0 14 * * 5' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - # Override automatic language detection by changing the below list - # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] - language: ['python'] - # Learn more... - # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - with: - # We must fetch at least the immediate parents so that if this is - # a pull request then we can checkout the head. - fetch-depth: 2 - - # If this run was triggered by a pull request event, then checkout - # the head of the pull request instead of the merge commit. - - run: git checkout HEAD^2 - if: ${{ github.event_name == 'pull_request' }} - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v1 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 From 653232edf474e447c552015f797ca62462266727 Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Mon, 24 Jul 2023 15:16:39 +0100 Subject: [PATCH 02/24] Experimental try at building with new system --- .github/workflows/build.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..9e50a4a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,26 @@ +name: Build + +on: [push, pull_request] + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + python-version: [3.6, 3.7, 3.8, 3.9, '3.10'] + + steps: + - uses: actions/checkout@v3 + + - name: Build wheels + uses: pypa/cibuildwheel@v2.14.1 + with: + package-dir: . + output-dir: wheelhouse + config-file: "{package}/pyproject.toml" + + - uses: actions/upload-artifact@v3 + with: + path: ./wheelhouse/*.whl \ No newline at end of file From 1383572013bb27aa60d7cb73651e883ca0faa834 Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Tue, 25 Jul 2023 14:10:11 +0100 Subject: [PATCH 03/24] Restructured to use updated deploy system --- .github/workflows/build.yml | 33 +++++++- .github/workflows/deploy.yml | 77 +++++++++++++++++++ .../{pythonpackage.yml => pull_request.yml} | 0 .github/workflows/pythonpublish_linux.yml | 33 -------- .github/workflows/pythonpublish_mac.yml | 39 ---------- .github/workflows/pythonpublish_sdist.yml | 26 ------- .github/workflows/pythonpublish_windows.yml | 43 ----------- 7 files changed, 106 insertions(+), 145 deletions(-) create mode 100644 .github/workflows/deploy.yml rename .github/workflows/{pythonpackage.yml => pull_request.yml} (100%) delete mode 100644 .github/workflows/pythonpublish_linux.yml delete mode 100644 .github/workflows/pythonpublish_mac.yml delete mode 100644 .github/workflows/pythonpublish_sdist.yml delete mode 100644 .github/workflows/pythonpublish_windows.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9e50a4a..6a8ffe5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,10 @@ name: Build -on: [push, pull_request] +on: + push: + tags: + - "v*.*.*" + - "test-*" jobs: build_wheels: @@ -9,7 +13,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] - python-version: [3.6, 3.7, 3.8, 3.9, '3.10'] + python-version: [3.6, 3.7, 3.8, 3.9, '3.10', '3.11'] steps: - uses: actions/checkout@v3 @@ -18,9 +22,30 @@ jobs: uses: pypa/cibuildwheel@v2.14.1 with: package-dir: . - output-dir: wheelhouse + output-dir: dist config-file: "{package}/pyproject.toml" - uses: actions/upload-artifact@v3 with: - path: ./wheelhouse/*.whl \ No newline at end of file + name: v${{ github.ref }}/wheels + retention-days: 30 + path: dist/*.whl + + build_sdist: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.x" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + python setup.py sdist + - uses: actions/upload-artifact@v2 + with: + name: v${{ github.ref }}/sdist + retention-days: 30 + path: dist/*.tar.gz \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..f50d035 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,77 @@ +name: Deploy + +on: + release: + types: [created] + workflow_dispatch: + +jobs: + check_release_name_is_valid: + runs-on: ubuntu-latest + env: + IS_TEST_RELEASE: 'false' + steps: + - name: Check release name is valid + uses: actions/github-script@v4 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const releaseName = context.payload.release.name; + if (releaseName === undefined) { + core.setFailed('Release name is undefined'); + } else if (releaseName.match(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/)) || releaseName.match(/^test-[a-z0-9_]+$/i) { + core.info('Release name is valid'); + } else { + core.setFailed('Release name is invalid'); + } + + if releaseName.match(/^test-[a-z0-9_]+$/i) { + core.info('Release name is a test release'); + core.exportVariable('IS_TEST_RELEASE', 'true'); + } + - name: Ensure artifacts exist for this release name + uses: actions/github-script@v4 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const releaseName = context.payload.release.name; + const artifacts = await github.repos.listReleaseAssets({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: context.payload.release.id, + }); + const artifactNames = artifacts.data.map((artifact) => artifact.name); + if (artifactNames.length === 0) { + core.setFailed('No artifacts found for release'); + } else if (artifactNames.includes(`${releaseName}.tar.gz`) && artifactNames.includes(`${releaseName}-py3-none-any.whl`)) { + core.info('Artifacts found for release'); + } else { + core.setFailed('Artifacts found for release, but not the expected ones'); + } + - name: Retrieve wheel artifacts for release + uses: actions/download-artifact@v3 + with: + name: v${{ github.event.release.name }}/wheels + path: dist/*.whl + - name: Retrieve SDIST artifacts for release + uses: actions/download-artifact@v3 + with: + name: v${{ github.event.release.name }}/wheels + path: dist/*.tar.gz + - name: Release code as new release on Pypi + if: ${{ env.IS_TEST_RELEASE != 'true' }} + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_PASSWORD }} + repository-url: https://upload.pypi.org/legacy/ + verbose: true + + - name: "TEST: Release code as new release on Test Pypi" + if: ${{ env.IS_TEST_RELEASE == 'true' }} + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_TEST_PASSWORD }} + repository-url: https://test.pypi.org/legacy/ + verbose: true diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pull_request.yml similarity index 100% rename from .github/workflows/pythonpackage.yml rename to .github/workflows/pull_request.yml diff --git a/.github/workflows/pythonpublish_linux.yml b/.github/workflows/pythonpublish_linux.yml deleted file mode 100644 index 7f25a62..0000000 --- a/.github/workflows/pythonpublish_linux.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Upload Python Package (linux) - -on: - release: - types: [created] - workflow_dispatch: - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: "3.x" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine - - name: Build Linux - uses: RalfG/python-wheels-manylinux-build@v0.2.2-manylinux2010_x86_64 - with: - python-versions: "cp36-cp36m cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310" - build-requirements: "cython" - env: - USE_CYTHON: True - - name: Publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - twine upload wheelhouse/*-manylinux*.whl diff --git a/.github/workflows/pythonpublish_mac.yml b/.github/workflows/pythonpublish_mac.yml deleted file mode 100644 index 1753ab5..0000000 --- a/.github/workflows/pythonpublish_mac.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Upload Python Package (macOS) - -on: - release: - types: [created] - workflow_dispatch: - -jobs: - deploy: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [macos-latest] - architecture: [x64] - python-version: [3.7, 3.8, 3.9, '3.10'] - - steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - architecture: ${{ matrix.architecture }} - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine cython - - name: Build Mac - run: | - python setup.py bdist_wheel - shell: bash - env: - USE_CYTHON: True - - name: Publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - twine upload dist/*.whl diff --git a/.github/workflows/pythonpublish_sdist.yml b/.github/workflows/pythonpublish_sdist.yml deleted file mode 100644 index c7312fe..0000000 --- a/.github/workflows/pythonpublish_sdist.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Upload Python Package (SDIST) - -on: - release: - types: [created] - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: "3.x" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine - python setup.py sdist - - name: Publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - twine upload dist/* diff --git a/.github/workflows/pythonpublish_windows.yml b/.github/workflows/pythonpublish_windows.yml deleted file mode 100644 index 1f6acb8..0000000 --- a/.github/workflows/pythonpublish_windows.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Upload Python Package (windows) - -on: - release: - types: [created] - workflow_dispatch: - -jobs: - deploy: - runs-on: windows-latest - strategy: - max-parallel: 3 - matrix: - python-version: [3.7, 3.8, 3.9, '3.10'] - steps: - - uses: actions/checkout@v2 - - - name: Download Build Tools for Visual Studio 2019 - run: Invoke-WebRequest -Uri https://aka.ms/vs/16/release/vs_buildtools.exe -OutFile vs_buildtools.exe - - - name: Run vs_buildtools.exe install - run: ./vs_buildtools.exe --quiet --wait --norestart --nocache --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.VC.v141.x86.x64 --add Microsoft.VisualStudio.Component.VC.140 --includeRecommended - - - name: Set up Python ${{ matrix.python-version }} x64 - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - architecture: x64 - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine - - - name: Build binary wheel - run: python setup.py bdist_wheel - - - name: Publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - twine upload dist\upolygon-*.whl From a7b7208952e112d31ca897cdcebed6bd52b50dcd Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Tue, 25 Jul 2023 14:27:12 +0100 Subject: [PATCH 04/24] Correction to fix minor issue --- .github/workflows/build.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6a8ffe5..90397ce 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,6 +17,8 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Set env + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - name: Build wheels uses: pypa/cibuildwheel@v2.14.1 @@ -27,7 +29,7 @@ jobs: - uses: actions/upload-artifact@v3 with: - name: v${{ github.ref }}/wheels + name: v${{ env.RELEASE_VERSION }}-wheels retention-days: 30 path: dist/*.whl @@ -35,6 +37,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: Set env + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - name: Set up Python uses: actions/setup-python@v2 with: @@ -46,6 +50,6 @@ jobs: python setup.py sdist - uses: actions/upload-artifact@v2 with: - name: v${{ github.ref }}/sdist + name: v${{ env.RELEASE_VERSION }}-sdist retention-days: 30 path: dist/*.tar.gz \ No newline at end of file From acf4470538de6df45b6fe2fbb9b7ff65b52d992a Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Tue, 25 Jul 2023 14:50:31 +0100 Subject: [PATCH 05/24] Corrections to deploy, and minor improvement to prevent concurrent builds --- .github/workflows/build.yml | 8 ++++++-- .github/workflows/deploy.yml | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 90397ce..43f9201 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,6 +6,10 @@ on: - "v*.*.*" - "test-*" +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: build_wheels: name: Build wheels on ${{ matrix.os }} @@ -29,7 +33,7 @@ jobs: - uses: actions/upload-artifact@v3 with: - name: v${{ env.RELEASE_VERSION }}-wheels + name: ${{ env.RELEASE_VERSION }}-wheels retention-days: 30 path: dist/*.whl @@ -50,6 +54,6 @@ jobs: python setup.py sdist - uses: actions/upload-artifact@v2 with: - name: v${{ env.RELEASE_VERSION }}-sdist + name: ${{ env.RELEASE_VERSION }}-sdist retention-days: 30 path: dist/*.tar.gz \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f50d035..c71b4e1 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -51,12 +51,12 @@ jobs: - name: Retrieve wheel artifacts for release uses: actions/download-artifact@v3 with: - name: v${{ github.event.release.name }}/wheels + name: ${{ github.event.release.name }}-wheels path: dist/*.whl - name: Retrieve SDIST artifacts for release uses: actions/download-artifact@v3 with: - name: v${{ github.event.release.name }}/wheels + name: ${{ github.event.release.name }}-sdist path: dist/*.tar.gz - name: Release code as new release on Pypi if: ${{ env.IS_TEST_RELEASE != 'true' }} From 36d99d4e37da279a8e707c16e458850236c4f660 Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Tue, 25 Jul 2023 15:00:57 +0100 Subject: [PATCH 06/24] Set retention to 15 days --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 43f9201..f384cd7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,7 +34,7 @@ jobs: - uses: actions/upload-artifact@v3 with: name: ${{ env.RELEASE_VERSION }}-wheels - retention-days: 30 + retention-days: 15 path: dist/*.whl build_sdist: @@ -55,5 +55,5 @@ jobs: - uses: actions/upload-artifact@v2 with: name: ${{ env.RELEASE_VERSION }}-sdist - retention-days: 30 + retention-days: 15 path: dist/*.tar.gz \ No newline at end of file From e6277eeed1c5dd16bf0db95372ad253b4f483bcb Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Tue, 25 Jul 2023 15:05:21 +0100 Subject: [PATCH 07/24] Update that avoids extraneous version being created --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f384cd7..9791d80 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,6 +33,7 @@ jobs: - uses: actions/upload-artifact@v3 with: + if: ${{ env.RELEASE_VERSION != ''}} name: ${{ env.RELEASE_VERSION }}-wheels retention-days: 15 path: dist/*.whl @@ -54,6 +55,7 @@ jobs: python setup.py sdist - uses: actions/upload-artifact@v2 with: + if: ${{ env.RELEASE_VERSION != ''}} name: ${{ env.RELEASE_VERSION }}-sdist retention-days: 15 path: dist/*.tar.gz \ No newline at end of file From 848bc2f53113a5837a3d1aab6ddef491c33ce3ef Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Wed, 26 Jul 2023 10:10:49 +0100 Subject: [PATCH 08/24] Minor fix to YAML --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9791d80..18344c3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,8 +32,8 @@ jobs: config-file: "{package}/pyproject.toml" - uses: actions/upload-artifact@v3 + if: ${{ env.RELEASE_VERSION != ''}} with: - if: ${{ env.RELEASE_VERSION != ''}} name: ${{ env.RELEASE_VERSION }}-wheels retention-days: 15 path: dist/*.whl @@ -54,8 +54,8 @@ jobs: pip install setuptools wheel twine python setup.py sdist - uses: actions/upload-artifact@v2 + if: ${{ env.RELEASE_VERSION != ''}} with: - if: ${{ env.RELEASE_VERSION != ''}} name: ${{ env.RELEASE_VERSION }}-sdist retention-days: 15 path: dist/*.tar.gz \ No newline at end of file From 92f5f7fc27c0fb7b9eb240cccde2ae39dab4d71a Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Wed, 26 Jul 2023 10:12:15 +0100 Subject: [PATCH 09/24] Temp change to deploy process to ensure it doesn't try to deploy live --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c71b4e1..5411a4a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -64,7 +64,7 @@ jobs: with: user: __token__ password: ${{ secrets.PYPI_PASSWORD }} - repository-url: https://upload.pypi.org/legacy/ + repository-url: https://PREVENTFORTESTING.upload.pypi.org/legacy/ verbose: true - name: "TEST: Release code as new release on Test Pypi" From 4085b4b644a230cbeac700232ef0b01cba6da8e1 Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Wed, 26 Jul 2023 10:21:52 +0100 Subject: [PATCH 10/24] Correction to deploy.yml syntax --- .github/workflows/deploy.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 5411a4a..07c093a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,9 +1,9 @@ name: Deploy on: - release: - types: [created] - workflow_dispatch: + release: + types: [created] + workflow_dispatch: jobs: check_release_name_is_valid: From 7062382df7847a3452c4d17770187ad0cb9280fd Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Wed, 26 Jul 2023 10:31:48 +0100 Subject: [PATCH 11/24] Trying to make GHA happy with the triggers --- .github/workflows/build.yml | 1 + .github/workflows/pull_request.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 18344c3..4fce4dc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,6 +5,7 @@ on: tags: - "v*.*.*" - "test-*" + workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 6bd802c..988e39f 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -1,6 +1,6 @@ name: Python package -on: [pull_request] +on: [pull_request, workflow_dispatch] jobs: build: From b2fed0d7141bc71e39e13efdea8d3c5b243cd234 Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Wed, 26 Jul 2023 11:24:30 +0100 Subject: [PATCH 12/24] Temporary change to allow manual running of these steps --- .github/workflows/build.yml | 4 +++- .github/workflows/deploy.yml | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4fce4dc..ff49e5a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,7 +5,9 @@ on: tags: - "v*.*.*" - "test-*" - workflow_dispatch: + pull_request: + branches: + - master concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 07c093a..3fd26a4 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,7 +3,9 @@ name: Deploy on: release: types: [created] - workflow_dispatch: + pull_request: + branches: + - master jobs: check_release_name_is_valid: From b351c66ddfe544f2a53e11c19dabf8143505e47c Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Wed, 26 Jul 2023 11:36:30 +0100 Subject: [PATCH 13/24] Revert temp change --- .github/workflows/build.yml | 4 +--- .github/workflows/deploy.yml | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ff49e5a..4fce4dc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,9 +5,7 @@ on: tags: - "v*.*.*" - "test-*" - pull_request: - branches: - - master + workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3fd26a4..07c093a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,9 +3,7 @@ name: Deploy on: release: types: [created] - pull_request: - branches: - - master + workflow_dispatch: jobs: check_release_name_is_valid: From 78adcb3e125a462f6663a476356f8e59f5d7fd97 Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Wed, 26 Jul 2023 11:47:43 +0100 Subject: [PATCH 14/24] Fix to the JS of the tag checker --- .github/workflows/deploy.yml | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 07c093a..3f7ce74 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -16,19 +16,21 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const releaseName = context.payload.release.name; - if (releaseName === undefined) { - core.setFailed('Release name is undefined'); - } else if (releaseName.match(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/)) || releaseName.match(/^test-[a-z0-9_]+$/i) { - core.info('Release name is valid'); - } else { - core.setFailed('Release name is invalid'); - } + const releaseName = context.payload.release.name; + const SEMVER_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/; + const TEST_RELEASE_REGEX = /^test-[a-z0-9_]+$/i; + if (releaseName === undefined) { + core.setFailed('Release name is undefined'); + } else if (releaseName.match(SEMVER_REGEX) || releaseName.match(TEST_RELEASE_REGEX) { + core.info('Release name is valid'); + } else { + core.setFailed('Release name is invalid'); + } - if releaseName.match(/^test-[a-z0-9_]+$/i) { - core.info('Release name is a test release'); - core.exportVariable('IS_TEST_RELEASE', 'true'); - } + if releaseName.match(/^test-[a-z0-9_]+$/i) { + core.info('Release name is a test release'); + core.exportVariable('IS_TEST_RELEASE', 'true'); + } - name: Ensure artifacts exist for this release name uses: actions/github-script@v4 with: From 2d72d9b981e39fba75bb8ccd6b689e31eb8a0f7c Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Wed, 26 Jul 2023 12:01:05 +0100 Subject: [PATCH 15/24] Further syntax issue fixed --- .github/workflows/deploy.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3f7ce74..689a98b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -19,15 +19,16 @@ jobs: const releaseName = context.payload.release.name; const SEMVER_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/; const TEST_RELEASE_REGEX = /^test-[a-z0-9_]+$/i; + if (releaseName === undefined) { core.setFailed('Release name is undefined'); - } else if (releaseName.match(SEMVER_REGEX) || releaseName.match(TEST_RELEASE_REGEX) { + } else if (releaseName.match(SEMVER_REGEX) || releaseName.match(TEST_RELEASE_REGEX)) { core.info('Release name is valid'); } else { core.setFailed('Release name is invalid'); } - - if releaseName.match(/^test-[a-z0-9_]+$/i) { + + if (releaseName.match(TEST_RELEASE_REGEX)) { core.info('Release name is a test release'); core.exportVariable('IS_TEST_RELEASE', 'true'); } From 4bc986e37424d325ad7216ae0646614b512e4252 Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Wed, 26 Jul 2023 12:30:44 +0100 Subject: [PATCH 16/24] Testing --- .github/workflows/deploy.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 689a98b..04aa374 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -16,7 +16,8 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const releaseName = context.payload.release.name; + const releaseName = context.github.ref_name; + console.log(`Release name is ${releaseName}`) const SEMVER_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/; const TEST_RELEASE_REGEX = /^test-[a-z0-9_]+$/i; From e4f2303d1681b43c907f8859beb48a418bb93ef1 Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Wed, 26 Jul 2023 12:32:42 +0100 Subject: [PATCH 17/24] Another try --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 04aa374..1dc87c3 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -16,7 +16,7 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const releaseName = context.github.ref_name; + const releaseName = github.ref_name; console.log(`Release name is ${releaseName}`) const SEMVER_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/; const TEST_RELEASE_REGEX = /^test-[a-z0-9_]+$/i; From e5f02471968e3b11447aa7cb058fa30309494e7d Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Wed, 26 Jul 2023 12:34:04 +0100 Subject: [PATCH 18/24] Elucidating whole object --- .github/workflows/deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1dc87c3..ff7d4bc 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -16,6 +16,7 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | + console.log(JSON.stringify(context, null, 2)); const releaseName = github.ref_name; console.log(`Release name is ${releaseName}`) const SEMVER_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/; From 77c1cb1d9388bdcd77cdeeb9ca0db90c8ada197c Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Wed, 26 Jul 2023 12:35:22 +0100 Subject: [PATCH 19/24] Alternative approach --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ff7d4bc..b325699 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -16,7 +16,7 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - console.log(JSON.stringify(context, null, 2)); + core.debug(JSON.stringify(context, null, 2)); const releaseName = github.ref_name; console.log(`Release name is ${releaseName}`) const SEMVER_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/; From 2bed740387a194cd21263968ab600e066f6e2a93 Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Wed, 26 Jul 2023 12:37:50 +0100 Subject: [PATCH 20/24] Trying to debug --- .github/workflows/deploy.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b325699..185ce23 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -17,7 +17,8 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} script: | core.debug(JSON.stringify(context, null, 2)); - const releaseName = github.ref_name; + const releaseName = "context.payload.release.name"; + //const releaseName = context.payload.release.name; console.log(`Release name is ${releaseName}`) const SEMVER_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/; const TEST_RELEASE_REGEX = /^test-[a-z0-9_]+$/i; From 277104bc7ae3b22928d26baa70ff268b93183567 Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Wed, 26 Jul 2023 13:15:11 +0100 Subject: [PATCH 21/24] Move away from JS entirely --- .github/workflows/deploy.yml | 51 ++++++------------------------------ 1 file changed, 8 insertions(+), 43 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 185ce23..43ea47c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -11,49 +11,14 @@ jobs: env: IS_TEST_RELEASE: 'false' steps: - - name: Check release name is valid - uses: actions/github-script@v4 + - name: Ensure wheels exist for this release name + uses: xSAVIKx/artifact-exists-action@v0 with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - core.debug(JSON.stringify(context, null, 2)); - const releaseName = "context.payload.release.name"; - //const releaseName = context.payload.release.name; - console.log(`Release name is ${releaseName}`) - const SEMVER_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/; - const TEST_RELEASE_REGEX = /^test-[a-z0-9_]+$/i; - - if (releaseName === undefined) { - core.setFailed('Release name is undefined'); - } else if (releaseName.match(SEMVER_REGEX) || releaseName.match(TEST_RELEASE_REGEX)) { - core.info('Release name is valid'); - } else { - core.setFailed('Release name is invalid'); - } - - if (releaseName.match(TEST_RELEASE_REGEX)) { - core.info('Release name is a test release'); - core.exportVariable('IS_TEST_RELEASE', 'true'); - } - - name: Ensure artifacts exist for this release name - uses: actions/github-script@v4 + name: ${{ github.event.release.name }}-wheels + - name: Ensure SDIST exists for this release name + uses: xSAVIKx/artifact-exists-action@v0 with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const releaseName = context.payload.release.name; - const artifacts = await github.repos.listReleaseAssets({ - owner: context.repo.owner, - repo: context.repo.repo, - release_id: context.payload.release.id, - }); - const artifactNames = artifacts.data.map((artifact) => artifact.name); - if (artifactNames.length === 0) { - core.setFailed('No artifacts found for release'); - } else if (artifactNames.includes(`${releaseName}.tar.gz`) && artifactNames.includes(`${releaseName}-py3-none-any.whl`)) { - core.info('Artifacts found for release'); - } else { - core.setFailed('Artifacts found for release, but not the expected ones'); - } + name: ${{ github.event.release.name }}-sdist - name: Retrieve wheel artifacts for release uses: actions/download-artifact@v3 with: @@ -65,7 +30,7 @@ jobs: name: ${{ github.event.release.name }}-sdist path: dist/*.tar.gz - name: Release code as new release on Pypi - if: ${{ env.IS_TEST_RELEASE != 'true' }} + if: ${{ startsWith(github.event.release.name,'v') }} uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ @@ -74,7 +39,7 @@ jobs: verbose: true - name: "TEST: Release code as new release on Test Pypi" - if: ${{ env.IS_TEST_RELEASE == 'true' }} + if: ${{ startsWith(github.event.release.name,'test-') }} uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ From 02b5fe976197e0b686822d21ac78d9c5ed86efed Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Wed, 26 Jul 2023 13:19:23 +0100 Subject: [PATCH 22/24] New structure for non-concurrency --- .github/workflows/deploy.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 43ea47c..bd3a119 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -6,10 +6,8 @@ on: workflow_dispatch: jobs: - check_release_name_is_valid: + check_artifacts: runs-on: ubuntu-latest - env: - IS_TEST_RELEASE: 'false' steps: - name: Ensure wheels exist for this release name uses: xSAVIKx/artifact-exists-action@v0 @@ -19,6 +17,10 @@ jobs: uses: xSAVIKx/artifact-exists-action@v0 with: name: ${{ github.event.release.name }}-sdist + + retrieve_artifacts: + runs-on: ubuntu-latest + steps: - name: Retrieve wheel artifacts for release uses: actions/download-artifact@v3 with: @@ -29,6 +31,11 @@ jobs: with: name: ${{ github.event.release.name }}-sdist path: dist/*.tar.gz + + deploy: + needs: [check_artifacts, retrieve_artifacts] + runs-on: ubuntu-latest + steps: - name: Release code as new release on Pypi if: ${{ startsWith(github.event.release.name,'v') }} uses: pypa/gh-action-pypi-publish@release/v1 From 8c94cadc70f5309aee33d4d602aaa48812570aa0 Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Wed, 26 Jul 2023 13:24:13 +0100 Subject: [PATCH 23/24] Chained pipeline --- .github/workflows/deploy.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index bd3a119..507ae5a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -10,16 +10,30 @@ jobs: runs-on: ubuntu-latest steps: - name: Ensure wheels exist for this release name + id: wheels_exist uses: xSAVIKx/artifact-exists-action@v0 with: name: ${{ github.event.release.name }}-wheels - name: Ensure SDIST exists for this release name + id: sdist_exists uses: xSAVIKx/artifact-exists-action@v0 with: name: ${{ github.event.release.name }}-sdist + - name: Fail if no wheels or SDIST exists + run: | + if [ -z "${{ steps.wheels_exist.outputs.exists }}" ]; then + echo "No wheels found for release ${{ github.event.release.name }}"; + exit 1; + fi + + if [ -z "${{ steps.sdist_exists.outputs.exists }}" ]; then + echo "No wheels found for release ${{ github.event.release.name }}"; + exit 1; + fi retrieve_artifacts: runs-on: ubuntu-latest + needs: check_artifacts steps: - name: Retrieve wheel artifacts for release uses: actions/download-artifact@v3 From 4489bc7bf310129cce8d1cb867067e7d16db9787 Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Wed, 26 Jul 2023 13:31:42 +0100 Subject: [PATCH 24/24] YARefactor to minimise the code --- .github/workflows/deploy.yml | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 507ae5a..c10eecc 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -6,34 +6,9 @@ on: workflow_dispatch: jobs: - check_artifacts: - runs-on: ubuntu-latest - steps: - - name: Ensure wheels exist for this release name - id: wheels_exist - uses: xSAVIKx/artifact-exists-action@v0 - with: - name: ${{ github.event.release.name }}-wheels - - name: Ensure SDIST exists for this release name - id: sdist_exists - uses: xSAVIKx/artifact-exists-action@v0 - with: - name: ${{ github.event.release.name }}-sdist - - name: Fail if no wheels or SDIST exists - run: | - if [ -z "${{ steps.wheels_exist.outputs.exists }}" ]; then - echo "No wheels found for release ${{ github.event.release.name }}"; - exit 1; - fi - - if [ -z "${{ steps.sdist_exists.outputs.exists }}" ]; then - echo "No wheels found for release ${{ github.event.release.name }}"; - exit 1; - fi retrieve_artifacts: runs-on: ubuntu-latest - needs: check_artifacts steps: - name: Retrieve wheel artifacts for release uses: actions/download-artifact@v3 @@ -47,7 +22,7 @@ jobs: path: dist/*.tar.gz deploy: - needs: [check_artifacts, retrieve_artifacts] + needs: retrieve_artifacts runs-on: ubuntu-latest steps: - name: Release code as new release on Pypi