From 25bc22c0ccf2c29c4f8f21924101b1b7b25fe0e3 Mon Sep 17 00:00:00 2001 From: melanylibia Date: Sun, 19 May 2024 19:31:35 -0400 Subject: [PATCH 01/10] feat: GitHub Action to auto-publish to PyPI --- .github/workflows/release.yml | 88 +++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..1debf9e2 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,88 @@ +name: Release + +on: + push: + branches: + - master + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + # linux + - os: ubuntu-latest + python: "3.12" + toxenv: py312 + - os: ubuntu-latest + python: "3.11" + toxenv: py311 + - os: ubuntu-latest + python: "3.10" + toxenv: py310 + - os: ubuntu-latest + python: "3.9" + toxenv: py39 + - os: ubuntu-latest + python: "3.8" + toxenv: py38 + # windows + - os: windows-latest + python: "3.12" + toxenv: py312 + - os: windows-latest + python: "3.11" + toxenv: py311 + - os: windows-latest + python: "3.10" + toxenv: py310 + - os: windows-latest + python: "3.9" + toxenv: py39 + - os: windows-latest + python: "3.8" + toxenv: py38 + # macos + - os: macos-latest + python: "3.12" + toxenv: py312 + - os: macos-latest + python: "3.11" + toxenv: py311 + - os: macos-latest + python: "3.10" + toxenv: py310 + - os: macos-latest + python: "3.9" + toxenv: py39 + - os: macos-latest + python: "3.8" + toxenv: py38 + # misc + - os: ubuntu-latest + python: "3.11" + toxenv: pylama + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + + - name: Install dependencies + run: python -m pip install -U build + + - name: Build package + run: python -m build + + - name: Publish package to PyPI + if: github.repository == 'mozilla/mozdownload' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: ${{ secrets.pypi_user }} + repository-url: https://test.pypi.org/legacy/ + password: ${{ secrets.pypi_password }} \ No newline at end of file From a8843021f198ac78be59354e248503474c8083f8 Mon Sep 17 00:00:00 2001 From: melanylibia Date: Sun, 19 May 2024 19:33:34 -0400 Subject: [PATCH 02/10] feat: build isolation feature of pip --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..e2e407db --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ['setuptools>=40'] +build-backend = 'setuptools.build_meta' \ No newline at end of file From 18d8275ddc2590e3e7f7f2d004f9322eb45bbc4e Mon Sep 17 00:00:00 2001 From: melanylibia Date: Sun, 19 May 2024 20:00:14 -0400 Subject: [PATCH 03/10] feat: updated GitHub Action versions --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1debf9e2..abfede5e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -66,10 +66,10 @@ jobs: toxenv: pylama steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} From c3b3ea370b0b0ddcf812ea795b7a9e7898589c79 Mon Sep 17 00:00:00 2001 From: melanylibia Date: Wed, 22 May 2024 16:53:30 -0400 Subject: [PATCH 04/10] fix: Refactor jobs, streamline runs-on, and optimize conditionals. --- .github/workflows/release.yml | 93 +++++++++++------------------------ 1 file changed, 29 insertions(+), 64 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index abfede5e..13797f69 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,82 +7,47 @@ on: jobs: build: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - include: - # linux - - os: ubuntu-latest - python: "3.12" - toxenv: py312 - - os: ubuntu-latest - python: "3.11" - toxenv: py311 - - os: ubuntu-latest - python: "3.10" - toxenv: py310 - - os: ubuntu-latest - python: "3.9" - toxenv: py39 - - os: ubuntu-latest - python: "3.8" - toxenv: py38 - # windows - - os: windows-latest - python: "3.12" - toxenv: py312 - - os: windows-latest - python: "3.11" - toxenv: py311 - - os: windows-latest - python: "3.10" - toxenv: py310 - - os: windows-latest - python: "3.9" - toxenv: py39 - - os: windows-latest - python: "3.8" - toxenv: py38 - # macos - - os: macos-latest - python: "3.12" - toxenv: py312 - - os: macos-latest - python: "3.11" - toxenv: py311 - - os: macos-latest - python: "3.10" - toxenv: py310 - - os: macos-latest - python: "3.9" - toxenv: py39 - - os: macos-latest - python: "3.8" - toxenv: py38 - # misc - - os: ubuntu-latest - python: "3.11" - toxenv: pylama - + name: Build package + runs-on: ubuntu-latest + env: + PYTHON_VERSION: ${{ secrets.PYTHON_VERSION }} steps: - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python }} + - name: Set up Python ${{ vars.PYTHON_VERSION }} uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python }} + python-version: ${{ vars.PYTHON_VERSION }} - name: Install dependencies run: python -m pip install -U build - name: Build package - run: python -m build + run: python -m build - - name: Publish package to PyPI - if: github.repository == 'mozilla/mozdownload' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + - name: Upload dist folder + uses: actions/upload-artifact@v4 + with: + name: dist_directory + path: dist + + pypi-publish: + name: Upload release to PyPI + runs-on: ubuntu-latest + needs: build + env: + TOKEN: ${{ secrets.pypi_token }} + steps: + - name: Download dist folder + uses: actions/download-artifact@v4 + id: download + with: + name: dist_directory + path: dist + - name: Publish package to PyPI + if: steps.download.conclusion == 'success' && env.TOKEN != '' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@release/v1 with: user: ${{ secrets.pypi_user }} repository-url: https://test.pypi.org/legacy/ - password: ${{ secrets.pypi_password }} \ No newline at end of file + password: ${{ secrets.pypi_token }} \ No newline at end of file From a81238610dea38c24497c975c86c41926f798ad0 Mon Sep 17 00:00:00 2001 From: melanylibia Date: Wed, 22 May 2024 17:33:45 -0400 Subject: [PATCH 05/10] fix: removed unnecessary file --- pyproject.toml | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index e2e407db..00000000 --- a/pyproject.toml +++ /dev/null @@ -1,3 +0,0 @@ -[build-system] -requires = ['setuptools>=40'] -build-backend = 'setuptools.build_meta' \ No newline at end of file From 1dd27ee99d3a12ac848c03c3da9fb550bb7b5ea3 Mon Sep 17 00:00:00 2001 From: melanylibia Date: Thu, 30 May 2024 12:41:41 -0400 Subject: [PATCH 06/10] fix: improve jobs, change messages --- .github/workflows/release.yml | 43 ++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 13797f69..b7bb20bd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,48 +6,59 @@ on: - master jobs: + check-token: + runs-on: ubuntu-latest + steps: + - name: Check token variable + env: + PYPI_TOKEN_VAR: ${{ secrets.pypi_token }} + run: | + if [ -z "$PYPI_TOKEN_VAR" ]; then + echo "Pypi token variable is empty!" + exit 1 + fi + echo "Pypi token variable is set!" build: name: Build package + needs: check-token runs-on: ubuntu-latest - env: - PYTHON_VERSION: ${{ secrets.PYTHON_VERSION }} steps: - uses: actions/checkout@v4 - - name: Set up Python ${{ vars.PYTHON_VERSION }} + - name: Set up Python 3.12 uses: actions/setup-python@v5 with: - python-version: ${{ vars.PYTHON_VERSION }} + python-version: 3.12 - name: Install dependencies run: python -m pip install -U build - - name: Build package + - name: Build a binary wheel and a source tarball run: python -m build - - name: Upload dist folder + - name: Store the distribution packages uses: actions/upload-artifact@v4 with: - name: dist_directory + name: python-package-distributions path: dist pypi-publish: name: Upload release to PyPI runs-on: ubuntu-latest - needs: build - env: - TOKEN: ${{ secrets.pypi_token }} + environment: + name: pypi + url: https://pypi.org/p/mozdownload + permissions: + id-token: write + needs: [check-token, build] steps: - name: Download dist folder uses: actions/download-artifact@v4 - id: download with: - name: dist_directory + name: python-package-distributions path: dist - - name: Publish package to PyPI - if: steps.download.conclusion == 'success' && env.TOKEN != '' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + - name: Upload release to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: - user: ${{ secrets.pypi_user }} - repository-url: https://test.pypi.org/legacy/ + packages_dir: dist/ password: ${{ secrets.pypi_token }} \ No newline at end of file From 292442c31968fd620278045a9b39db2e75d006b6 Mon Sep 17 00:00:00 2001 From: melanylibia Date: Wed, 12 Jun 2024 14:30:59 -0400 Subject: [PATCH 07/10] fix: fixed job deploy --- .github/workflows/release.yml | 46 ++++++----------------------------- 1 file changed, 7 insertions(+), 39 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b7bb20bd..545a68e7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,22 +6,14 @@ on: - master jobs: - check-token: - runs-on: ubuntu-latest - steps: - - name: Check token variable - env: - PYPI_TOKEN_VAR: ${{ secrets.pypi_token }} - run: | - if [ -z "$PYPI_TOKEN_VAR" ]; then - echo "Pypi token variable is empty!" - exit 1 - fi - echo "Pypi token variable is set!" - build: - name: Build package - needs: check-token + deploy: + name: Upload release to PyPI runs-on: ubuntu-latest + environment: + name: release + url: https://pypi.org/p/mozdownload + permissions: + id-token: write steps: - uses: actions/checkout@v4 @@ -36,29 +28,5 @@ jobs: - name: Build a binary wheel and a source tarball run: python -m build - - name: Store the distribution packages - uses: actions/upload-artifact@v4 - with: - name: python-package-distributions - path: dist - - pypi-publish: - name: Upload release to PyPI - runs-on: ubuntu-latest - environment: - name: pypi - url: https://pypi.org/p/mozdownload - permissions: - id-token: write - needs: [check-token, build] - steps: - - name: Download dist folder - uses: actions/download-artifact@v4 - with: - name: python-package-distributions - path: dist - name: Upload release to PyPI uses: pypa/gh-action-pypi-publish@release/v1 - with: - packages_dir: dist/ - password: ${{ secrets.pypi_token }} \ No newline at end of file From 803d60fe62b8659559032e6847e2e2dafd124fd6 Mon Sep 17 00:00:00 2001 From: melanylibia Date: Tue, 2 Jul 2024 12:13:04 -0400 Subject: [PATCH 08/10] feat: added release workflow to trigger on test completion and handle failures. --- .github/workflows/release.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 545a68e7..b6b2a0d5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,14 +1,16 @@ name: Release on: - push: - branches: - - master + workflow_run: + workflows: [ Test ] + types: [ completed ] + branches: [ master ] jobs: deploy: name: Upload release to PyPI runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} environment: name: release url: https://pypi.org/p/mozdownload @@ -30,3 +32,8 @@ jobs: - name: Upload release to PyPI uses: pypa/gh-action-pypi-publish@release/v1 + on-failure: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'failure' }} + steps: + - run: echo "Test has failed" \ No newline at end of file From f554d007c7f251c7ee5971e083a52fbb8a82fc2d Mon Sep 17 00:00:00 2001 From: LibiaMLany <82403984+libialany@users.noreply.github.com> Date: Fri, 5 Jul 2024 08:08:32 -0400 Subject: [PATCH 09/10] Update release.yml --- .github/workflows/release.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b6b2a0d5..e9b5613f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ jobs: deploy: name: Upload release to PyPI runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} + if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' }} environment: name: release url: https://pypi.org/p/mozdownload @@ -32,8 +32,4 @@ jobs: - name: Upload release to PyPI uses: pypa/gh-action-pypi-publish@release/v1 - on-failure: - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'failure' }} - steps: - - run: echo "Test has failed" \ No newline at end of file + From ba7e599f937b62d8dfca0f42bf038c10235ff8ae Mon Sep 17 00:00:00 2001 From: LibiaMLany <82403984+libialany@users.noreply.github.com> Date: Fri, 5 Jul 2024 08:09:59 -0400 Subject: [PATCH 10/10] Update release.yml --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e9b5613f..510f215c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,3 +33,4 @@ jobs: - name: Upload release to PyPI uses: pypa/gh-action-pypi-publish@release/v1 +