Merge pull request #1186 from cloudbees-oss/v1-sync #20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Publish workflow for the Smart Tests CLI | |
| # Builds and publishes packages to PyPI and Docker Hub | |
| name: Publish | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| env: | |
| IMAGE_NAME: cloudbees/smart-tests-cli | |
| jobs: | |
| tagpr: | |
| permissions: | |
| actions: write | |
| contents: write | |
| pull-requests: write | |
| runs-on: ubuntu-latest | |
| outputs: | |
| tag: ${{ steps.run-tagpr.outputs.tag }} | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - id: run-tagpr | |
| uses: Songmu/tagpr@7191605433b03e11b313dbbc0efb80185170de4b # v1.9.0 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| pypi: | |
| needs: tagpr | |
| if: needs.tagpr.outputs.tag != '' || github.event_name == 'workflow_dispatch' | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v3 | |
| - name: Build package | |
| run: uv build | |
| - name: Publish to PyPI | |
| run: uv publish --token ${{ secrets.SMART_TESTS_PYPI_API_TOKEN }} | |
| - name: Actions for Discord | |
| uses: Ilshidur/[email protected] | |
| env: | |
| DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} | |
| with: | |
| args: "Smart Tests CLI ${{ needs.tagpr.outputs.tag }} is released! https://github.com/launchableinc/cli/releases/tag/${{ needs.tagpr.outputs.tag }}" | |
| docker: | |
| name: Push Docker image to Docker Hub | |
| needs: tagpr | |
| if: needs.tagpr.outputs.tag != '' || github.event_name == 'workflow_dispatch' | |
| runs-on: ubuntu-22.04 | |
| permissions: | |
| packages: write | |
| contents: read | |
| attestations: write | |
| id-token: write | |
| steps: | |
| - name: Check out the repo | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0 | |
| - name: Build and push Docker image | |
| id: push | |
| uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ env.IMAGE_NAME }}:${{ needs.tagpr.outputs.tag }} | |
| - name: Generate artifact attestation | |
| uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be # v2.4.0 | |
| with: | |
| subject-name: index.docker.io/${{ env.IMAGE_NAME }} | |
| subject-digest: ${{ steps.push.outputs.digest }} | |
| push-to-registry: true |