Skip to content

Merge pull request #1127 from cloudbees-oss/subset-error-handling #535

Merge pull request #1127 from cloudbees-oss/subset-error-handling

Merge pull request #1127 from cloudbees-oss/subset-error-handling #535

# This workflows will upload a Python Package
# For more information see: https://github.com/marketplace/actions/pypi-publish
name: Upload Python Package
on:
workflow_dispatch:
push:
branches:
- v1
env:
IMAGE_NAME: cloudbees/launchable
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@e89d37247ca73d3e5620bf074a53fbd5b39e66b0 # v1.5.1
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: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
# build and publish package using GitHub Actions workflow
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
# actual publish
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Actions for Discord
uses: Ilshidur/action-discord@0.3.2
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
with:
args: 'Launchable CLI ${{ needs.tagpr.outputs.tag }} is released! https://github.com/cloudbees-oss/smart-tests-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