Skip to content

Create draft release #26

Create draft release

Create draft release #26

name: Create draft release
on:
workflow_dispatch:
inputs:
ref:
required: true
type: string
version:
required: true
type: string
description: 'The version of the plugin to release, e.g., 0.1.0'
jobs:
create-draft-release:
runs-on: ubuntu-24.04
permissions:
attestations: write
contents: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref || github.ref }}
- name: Setup Python 3.11.x
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Initialize Pants launcher
uses: pantsbuild/actions/init-pants@56efcdb79721bc7726edf542e324468033e4e21c
with:
# cache0 makes it easy to bust the cache if needed
gha-cache-key: cache0-py3.11
named-caches-hash: ${{ hashFiles('3rdparty/python/pants-2.27.lock') }}
env:
HONEYCOMB_API_KEY: ${{ secrets.HONEYCOMB_API_KEY }}
- name: Run tests
run: "pants test ::"
env:
HONEYCOMB_API_KEY: ${{ secrets.HONEYCOMB_API_KEY }}
- name: Package the plugin as a wheel
id: package
run: |
pants package src/python/shoalsoft/pants_opentelemetry_plugin:wheel
wheel_file="dist/shoalsoft_pants_opentelemetry_plugin-${{github.event.inputs.version}}-py3-none-any.whl"
if [ ! -r "$wheel_file" ]; then
ls dist/* || true
echo "ERROR: No wheel file found at $wheel_file." 1>&2
exit 1
fi
source_archive_file="dist/shoalsoft_pants_opentelemetry_plugin-${{github.event.inputs.version}}.tar.gz"
if [ ! -r "$source_archive_file" ]; then
ls dist/* || true
echo "ERROR: No wheel file found at $wheel_file." 1>&2
exit 1
fi
echo "wheel-local-path=$wheel_file" >> $GITHUB_OUTPUT
echo "source-archive-file=$source_archive_file" >> $GITHUB_OUTPUT
env:
HONEYCOMB_API_KEY: ${{ secrets.HONEYCOMB_API_KEY }}
- name: Attest provenance of the wheel and source archive.
uses: actions/attest-build-provenance@v2
with:
subject-path: |
${{ steps.package.outputs.wheel-local-path }}
${{ steps.package.outputs.source-archive-file }}
- name: Create the draft release.
uses: actions/github-script@v7
env:
PLUGIN_VERSION: ${{ github.event.inputs.version }}
REF: ${{ github.event.inputs.ref }}
with:
script: |
const pluginVersion = process.env.PLUGIN_VERSION;
const ref = process.env.REF;
const isPrerelease = pluginVersion.includes("dev") || pluginVersion.includes("rc");
const release = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: ref,
name: `v${pluginVersion}`,
body: `Release of version ${pluginVersion} of the Pants OpenTelemetry Plugin.`,
draft: true,
prerelease: isPrerelease,
});
return release.data;
- name: Upload the wheel and source archive to the draft release.
run: |
gh release upload ${{ github.event.inputs.ref }} ${{ steps.package.outputs.wheel-local-path }}
gh release upload ${{ github.event.inputs.ref }} ${{ steps.package.outputs.source-archive-file }}
env:
GH_TOKEN: ${{ github.token }}
- name: Upload pants.log
if: always()
uses: actions/upload-artifact@v4
continue-on-error: true
with:
name: pants-logs
overwrite: 'true'
path: .pants.d/workdir/*.log