diff --git a/.github/workflows/contraqctor.yml b/.github/workflows/contraqctor.yml index 1cd7875..227315e 100644 --- a/.github/workflows/contraqctor.yml +++ b/.github/workflows/contraqctor.yml @@ -1,19 +1,6 @@ name: contraqctor test suite on: - workflow_dispatch: - inputs: - bump_type: - description: "Version bump type" - required: false - default: "rc" - type: choice - options: - - rc - - patch - - minor - - major - - stable pull_request: push: branches: @@ -21,7 +8,7 @@ on: - dev* - release* release: - types: [published] + types: [ published ] jobs: # ╔──────────────────────────╗ @@ -37,13 +24,13 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, windows-latest] - python-version: [3.11, 3.12, 3.13] + os: [ ubuntu-latest, windows-latest ] + python-version: [ 3.11, 3.12, 3.13 ] fail-fast: false steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - - uses: astral-sh/setup-uv@v6 + - uses: astral-sh/setup-uv@v8.1.0 with: enable-cache: true @@ -76,60 +63,6 @@ jobs: # │ \____|___\____|____/ |_| \_\___|_|\___|\__,_|___/\___| │ # │ │ # ╚───────────────────────────────────────────────────────────╝ - github-rc-release: - needs: tests - runs-on: ubuntu-latest - if: > - github.ref == 'refs/heads/main' && - github.event_name == 'push' && - github.event.head_commit.author.email != 'github-actions[bot]@users.noreply.github.com' - name: Create GitHub pre-release - steps: - - uses: actions/checkout@v5 - with: - fetch-depth: 0 - ref: main - - - uses: astral-sh/setup-uv@v6 - with: - enable-cache: true - - - name: Bump pre-release by default - # Note: Bumping the rc will fail if the version is not currently an rc - # To solve it, we bump the patch and rc atomically - run: | - if uv version --bump rc --dry-run; then - uv version --bump rc - else - uv version --bump rc --bump patch - fi - - - name: Commit version - run: | - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git add . - git commit -m "Bump version [skip ci]" || echo "No changes to commit" - git push origin main - - - name: Get version - id: get_version - run: | - version=$(uv run uv version --short) - echo "version=$version" >> $GITHUB_OUTPUT - - - name: Create GitHub Release - uses: softprops/action-gh-release@v2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: v${{ steps.get_version.outputs.version }} - name: v${{ steps.get_version.outputs.version }} - generate_release_notes: true - prerelease: true - body: | - Automated pre-release v${{ steps.get_version.outputs.version }} - # ╔─────────────────────────────────────────────────────────────────╗ # │ ____ _ _ _ ____ _ │ # │ | _ \ _ _| |__ | (_) ___ | _ \ ___| | ___ __ _ ___ ___ │ @@ -139,134 +72,84 @@ jobs: # │ │ # ╚─────────────────────────────────────────────────────────────────╝ - prepare-public-release: + prepare-release: runs-on: ubuntu-latest - name: Prepare files for public release + name: Set version from release tag needs: tests - if: github.event_name == 'workflow_dispatch' + if: github.event_name == 'release' && github.event.action == 'published' outputs: version: ${{ steps.get_version.outputs.version }} - is_prerelease: ${{ steps.check_prerelease.outputs.prerelease }} steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 with: fetch-depth: 0 ref: main - - uses: astral-sh/setup-uv@v6 + - uses: astral-sh/setup-uv@v8.1.0 with: enable-cache: true - - name: Get target version + - name: Extract version from tag id: get_version + shell: bash run: | - # Use bump type from input (defaults to rc) - bump_type="${{ github.event.inputs.bump_type || 'rc' }}" - echo "Bumping version with type: $bump_type" - - # Handle version bumping based on type - if [[ "$bump_type" == "rc" ]]; then - # Handle rc bumping logic (same as in github-rc-release) - if uv version --bump rc --dry-run; then - uv version --bump rc - else - uv version --bump rc --bump patch - fi - else - # Handle patch, minor, major, stable - uv version --bump $bump_type - fi - - release_version=$(uv run uv version --short) - echo "version=$release_version" >> $GITHUB_OUTPUT - echo "Release version will be: $release_version" + version=$(echo "${{ github.event.release.tag_name }}" | sed 's/^v//') + echo "version=$version" >> $GITHUB_OUTPUT + echo "Setting version to: $version" - name: Validate version format run: uv version ${{ steps.get_version.outputs.version }} --dry-run - - name: Update package version + - name: Set version run: uv version ${{ steps.get_version.outputs.version }} - - name: Commit version and create tag + - name: Build + run: uv build + + - name: Upload wheels as artifact + uses: actions/upload-artifact@v4 + with: + name: dist + path: dist/ + retention-days: 1 + + - name: Commit version changes + shell: bash run: | git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" git add . - git commit -m "Release v${{ steps.get_version.outputs.version }} [skip ci]" - git tag -a "v${{ steps.get_version.outputs.version }}" -m "Release v${{ steps.get_version.outputs.version }}" + git diff --cached --quiet && echo "No changes to commit" && exit 0 + git commit -m "Set version ${{ steps.get_version.outputs.version }} [skip ci]" git push origin main - git push origin "v${{ steps.get_version.outputs.version }}" - - - name: Determine if prerelease - id: check_prerelease - shell: bash - run: | - version="${{ steps.get_version.outputs.version }}" - if [[ "$version" == *"rc"* ]]; then - echo "prerelease=true" >> $GITHUB_OUTPUT - else - echo "prerelease=false" >> $GITHUB_OUTPUT - fi - - - name: Create GitHub Release - uses: softprops/action-gh-release@v2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: v${{ steps.get_version.outputs.version }} - name: Release v${{ steps.get_version.outputs.version }} - generate_release_notes: true - prerelease: ${{ steps.check_prerelease.outputs.prerelease }} - body: | - Release v${{ steps.get_version.outputs.version }} - - This release was manually triggered. + # Move the release tag to point to this new commit. + git tag -fa "${{ github.event.release.tag_name }}" -m "${{ github.event.release.tag_name }}" + git push origin "${{ github.event.release.tag_name }}" --force publish-to-pypi: runs-on: ubuntu-latest name: Publish to PyPI - needs: [tests, prepare-public-release] - if: | - (github.event_name == 'workflow_dispatch') || - (github.event_name == 'release' && - github.event.action == 'published' && - !github.event.release.prerelease && - startsWith(github.ref, 'refs/tags/v')) + needs: prepare-release steps: - - uses: actions/checkout@v5 + - name: Download wheels artifact + uses: actions/download-artifact@v4 with: - fetch-depth: 0 - ref: ${{ github.event_name == 'workflow_dispatch' && 'main' || github.ref_name }} + name: dist + path: dist/ - - uses: astral-sh/setup-uv@v6 + - uses: astral-sh/setup-uv@v8.1.0 with: enable-cache: true - - name: Verify version consistency (for automatic releases) - if: github.event_name == 'release' - shell: bash - run: | - tag_version=$(echo "${{ github.ref_name }}" | sed 's/^v//') - package_version=$(uv run uv version --short) - if [[ "$tag_version" != "$package_version" ]]; then - echo "ERROR: Tag version ($tag_version) doesn't match package version ($package_version)" - exit 1 - fi - echo "✅ Version consistency verified: $tag_version" - - - name: Get current version (for manual releases) - if: github.event_name == 'workflow_dispatch' - run: | - package_version=$(uv run uv version --short) - echo "📦 Publishing version: $package_version" - - - name: Build - run: uv build - - name: Publish to PyPI run: uv publish --token ${{ secrets.AIND_PYPI_TOKEN }} + - name: Upload wheels to GitHub release + uses: softprops/action-gh-release@v3 + with: + files: dist/* + # ╔─────────────────────────╗ # │ ____ │ # │ | _ \ ___ ___ ___ │ @@ -278,14 +161,14 @@ jobs: build-docs: name: Build and deploy documentation to GitHub Pages runs-on: ubuntu-latest - needs: publish-to-pypi + needs: prepare-release if: github.event_name == 'release' && !github.event.release.prerelease steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Install uv - uses: astral-sh/setup-uv@v6 + uses: astral-sh/setup-uv@v8.1.0 with: enable-cache: true