From b5c59a98ee964e08e0e364561f88aef13022d166 Mon Sep 17 00:00:00 2001 From: petruki <31597636+petruki@users.noreply.github.com> Date: Fri, 24 Apr 2026 20:33:09 -0700 Subject: [PATCH] chore(ci): updated release workflows --- .github/workflows/release-test-conda.yml | 50 ---------------- .github/workflows/release-test.yml | 63 +++++++++++++++++++- .github/workflows/release.yml | 74 +++++++++++++++++++++++- sonar-project.properties | 2 +- switcher_client/version.py | 2 +- 5 files changed, 135 insertions(+), 56 deletions(-) delete mode 100644 .github/workflows/release-test-conda.yml diff --git a/.github/workflows/release-test-conda.yml b/.github/workflows/release-test-conda.yml deleted file mode 100644 index 987eb59..0000000 --- a/.github/workflows/release-test-conda.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Package Release Test Anaconda.org - -on: - workflow_dispatch: - -jobs: - publish-to-anaconda: - runs-on: ubuntu-latest - - environment: - name: anaconda - url: https://anaconda.org/switcherapi/switcher-client - - steps: - - uses: actions/checkout@v6 - - - name: Set up Miniconda - uses: conda-incubator/setup-miniconda@v3 - with: - auto-update-conda: true - python-version: "3.12" - channels: conda-forge - channel-priority: strict - conda-remove-defaults: true - - - name: Install build tools - shell: bash -el {0} - run: conda install -y conda-build anaconda-client - - - name: Get package version - shell: bash -el {0} - run: | - PKG_VER=$(grep '__version__' switcher_client/version.py | cut -d'"' -f2) - echo "PKG_VERSION=$PKG_VER" >> $GITHUB_ENV - printf "pkg_version:\n - $PKG_VER\n" > conda.recipe/conda_build_config.yaml - - - name: Build conda package - shell: bash -el {0} - run: conda build --no-test conda.recipe/ --output-folder dist/ -c conda-forge - - - name: Publish distribution to Anaconda.org - shell: bash -el {0} - run: | - anaconda \ - --token ${{ secrets.ANACONDA_TOKEN }} \ - upload \ - --user switcherapi \ - --label test \ - --force \ - $(find dist/ -name "*.tar.bz2" -o -name "*.conda") diff --git a/.github/workflows/release-test.yml b/.github/workflows/release-test.yml index 6602c3f..536bda3 100644 --- a/.github/workflows/release-test.yml +++ b/.github/workflows/release-test.yml @@ -1,11 +1,21 @@ -name: Package Release Test +name: Package Release Test (TestPyPi and Anaconda) on: workflow_dispatch: + inputs: + deploy_testpypi: + description: Publish to TestPyPI + type: boolean + default: false + deploy_anaconda: + description: Publish to Anaconda.org (test label) + type: boolean + default: false jobs: build: name: Build distribution + if: inputs.deploy_testpypi runs-on: ubuntu-latest steps: @@ -30,11 +40,12 @@ jobs: publish-to-testpypi: needs: build + if: inputs.deploy_testpypi runs-on: ubuntu-latest environment: name: testpypi - url: https://test.pypi.org/p/switcher_client + url: https://test.pypi.org/p/switcher-client permissions: id-token: write @@ -48,4 +59,50 @@ jobs: - name: Publish distribution to TestPyPI uses: pypa/gh-action-pypi-publish@release/v1 with: - repository-url: https://test.pypi.org/legacy/ \ No newline at end of file + repository-url: https://test.pypi.org/legacy/ + + publish-to-anaconda: + if: inputs.deploy_anaconda + runs-on: ubuntu-latest + + environment: + name: anaconda + url: https://anaconda.org/switcherapi/switcher-client + + steps: + - uses: actions/checkout@v6 + + - name: Set up Miniconda + uses: conda-incubator/setup-miniconda@v3 + with: + auto-update-conda: true + python-version: "3.12" + channels: conda-forge + channel-priority: strict + conda-remove-defaults: true + + - name: Install build tools + shell: bash -el {0} + run: conda install -y conda-build anaconda-client + + - name: Get package version + shell: bash -el {0} + run: | + PKG_VER=$(grep '__version__' switcher_client/version.py | cut -d'"' -f2) + echo "PKG_VERSION=$PKG_VER" >> $GITHUB_ENV + printf "pkg_version:\n - $PKG_VER\n" > conda.recipe/conda_build_config.yaml + + - name: Build conda package + shell: bash -el {0} + run: conda build --no-test conda.recipe/ --output-folder dist/ -c conda-forge + + - name: Publish distribution to Anaconda.org + shell: bash -el {0} + run: | + anaconda \ + --token ${{ secrets.ANACONDA_TOKEN }} \ + upload \ + --user switcherapi \ + --label test \ + --force \ + $(find dist/ -name "*.tar.bz2" -o -name "*.conda") \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c53ca51..7a6e013 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,8 +5,35 @@ on: types: [ created ] jobs: + test: + name: Test - Python ${{ matrix.python-version }} on ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] + os: [ ubuntu-latest, windows-latest ] + runs-on: ${{ matrix.os }} + + steps: + - name: Git checkout + uses: actions/checkout@v6 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + pip install pipenv + pipenv install --dev + + - name: Test + run: pipenv run pytest -v + build: name: Build distribution + needs: test runs-on: ubuntu-latest steps: @@ -35,7 +62,7 @@ jobs: runs-on: ubuntu-latest environment: name: pypi - url: https://pypi.org/p/switcher_client + url: https://pypi.org/p/switcher-client permissions: id-token: write @@ -47,3 +74,48 @@ jobs: path: dist/ - name: Publish distribution to PyPI uses: pypa/gh-action-pypi-publish@release/v1 + + publish-to-anaconda: + needs: + - build + runs-on: ubuntu-latest + environment: + name: anaconda + url: https://anaconda.org/switcherapi/switcher-client + + steps: + - uses: actions/checkout@v6 + + - name: Set up Miniconda + uses: conda-incubator/setup-miniconda@v3 + with: + auto-update-conda: true + python-version: "3.12" + channels: conda-forge + channel-priority: strict + conda-remove-defaults: true + + - name: Install build tools + shell: bash -el {0} + run: conda install -y conda-build anaconda-client + + - name: Get package version + shell: bash -el {0} + run: | + PKG_VER=$(grep '__version__' switcher_client/version.py | cut -d'"' -f2) + echo "PKG_VERSION=$PKG_VER" >> $GITHUB_ENV + printf "pkg_version:\n - $PKG_VER\n" > conda.recipe/conda_build_config.yaml + + - name: Build conda package + shell: bash -el {0} + run: conda build --no-test conda.recipe/ --output-folder dist/ -c conda-forge + + - name: Publish distribution to Anaconda.org + shell: bash -el {0} + run: | + anaconda \ + --token ${{ secrets.ANACONDA_TOKEN }} \ + upload \ + --user switcherapi \ + --label main \ + $(find dist/ -name "*.tar.bz2" -o -name "*.conda") diff --git a/sonar-project.properties b/sonar-project.properties index c631b15..00e49b3 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,7 +1,7 @@ sonar.projectKey=switcherapi_switcher-client-py sonar.projectName=switcher-client-py sonar.organization=switcherapi -sonar.projectVersion=0.1.1 +sonar.projectVersion=0.1.2 sonar.links.homepage=https://github.com/switcherapi/switcher-client-py sonar.sources=switcher_client diff --git a/switcher_client/version.py b/switcher_client/version.py index 485f44a..b3f4756 100644 --- a/switcher_client/version.py +++ b/switcher_client/version.py @@ -1 +1 @@ -__version__ = "0.1.1" +__version__ = "0.1.2"