Skip to content

Publish to PyPi and Create Release #148

Publish to PyPi and Create Release

Publish to PyPi and Create Release #148

# © 2023 SolarWinds Worldwide, LLC. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at:http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
name: Publish to PyPi and Create Release
on:
workflow_dispatch:
inputs:
version:
description: 'Semantic version of release (e.g. 1.0.0)'
required: true
env:
RELEASE_NAME: rel-${{ github.event.inputs.version }}
permissions:
id-token: write
contents: read
jobs:
is_publishable:
name: Check if version valid
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check version
run: cd .github/scripts && ./is_publishable.sh ${{ github.event.inputs.version }}
build_publish_sdist_and_x86_64:
name: Build and publish sdist and x86_64
needs: is_publishable
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/package_solarwinds_apm_x86_64
- name: Install Twine
run: pip install --upgrade --no-cache-dir --prefer-binary twine
- name: Check distribution artifacts
run: twine check dist/*
- name: Publish sdist and x86_64 wheels to PyPi
env:
TWINE_NON_INTERACTIVE: 1
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.SW_APM_PYPI_UPLOAD_TOKEN }}
run: twine upload dist/*
build_publish_aarch64:
name: Build and publish aarch64
needs:
- is_publishable
runs-on:
group: apm-arm-runner
steps:
- uses: actions/checkout@v4
- name: Build aarch64
uses: ./.github/actions/package_solarwinds_apm_aarch64
- name: Install Twine
run: pip install --upgrade --no-cache-dir --prefer-binary twine
- name: Check distribution artifacts
run: twine check dist/*
- name: Publish aarch64 wheels to TestPyPi
env:
TWINE_NON_INTERACTIVE: 1
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.SW_APM_PYPI_UPLOAD_TOKEN }}
run: twine upload dist/*.whl
create_release:
name: Create draft release
needs: [build_publish_sdist_and_x86_64, build_publish_aarch64]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: getsentry/action-github-app-token@v3
id: github-token
with:
app_id: ${{ vars.APPLICATION_ID }}
private_key: ${{ secrets.APPLICATION_PRIVATE_KEY }}
- uses: actions/checkout@v4
- name: Initialize git
run: |
git config user.name "GitHub Actions"
git config user.email noreply@github.com
- name: Create draft release
run: gh release create ${{ env.RELEASE_NAME }} --title "${{ env.RELEASE_NAME }}" --target release/${{ env.RELEASE_NAME }} --draft
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}