Skip to content

Add tags, assets, api-keys, and settings commands, bump version to 0.2.5 #8

Add tags, assets, api-keys, and settings commands, bump version to 0.2.5

Add tags, assets, api-keys, and settings commands, bump version to 0.2.5 #8

Workflow file for this run

on:
push:
tags: ["v[0-9]+", "v[0-9]+.[0-9]+", "v[0-9]+.[0-9]+.[0-9]+", "v[0-9]+.[0-9]+.[0-9]+-*"]
permissions:
contents: read
name: Release
jobs:
test:
uses: ./.github/workflows/ci.yaml
secrets: inherit
check_version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: check tag version == pyproject.version
id: version
run: |
pip install toml-cli
PROJECT_VERSION=$(toml get --toml-path pyproject.toml project.version)
TAG=$(git describe HEAD --tags --abbrev=0)
echo TAG: $TAG
echo "PROJECT_VERSION: $PROJECT_VERSION"
echo "project_version=$PROJECT_VERSION" >> $GITHUB_OUTPUT
if [[ "$TAG" != "v$PROJECT_VERSION" ]]; then exit 1; fi
- name: Check tag version > pypi version
run: |
LOCAL_VERSION=${{ steps.version.outputs.project_version }}
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" https://pypi.org/pypi/entropy-data-cli/json)
if [ "$RESPONSE" = "404" ]; then
echo "Package not yet on PyPI — first release, skipping version comparison"
exit 0
fi
PUBLIC_VERSION=$(curl -s https://pypi.org/pypi/entropy-data-cli/json | python3 -c "import sys,json; print(json.load(sys.stdin)['info']['version'])")
echo "Local version: $LOCAL_VERSION"
echo "Public version: $PUBLIC_VERSION"
pip install -q packaging
python3 -c "
from packaging.version import Version
local = Version('$LOCAL_VERSION')
public = Version('$PUBLIC_VERSION')
if local <= public:
raise SystemExit(f'Local version {local} must be higher than public version {public}')
print(f'{local} > {public}')
"
build:
runs-on: ubuntu-latest
needs:
- test
- check_version
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: "3.12"
- name: Build package
run: uv build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
publish-to-pypi:
name: >-
Publish Python distribution to PyPI
needs:
- build
runs-on: ubuntu-latest
environment:
name: release-pypi
url: https://pypi.org/p/entropy-data-cli
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
github-release:
name: >-
Create a GitHub Release
needs:
- publish-to-pypi
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Extract changelog for version
run: |
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#v}"
sed -n "/^## \[$VERSION\]/,/^## \[/p" CHANGELOG.md | head -n -1 > release_notes.md
cat release_notes.md
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--notes-file release_notes.md
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'
docker:
runs-on: ubuntu-latest
needs:
- test
- check_version
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
entropydata/entropy-data-cli
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
sbom: true
publish-to-testpypi:
name: Publish Python distribution to TestPyPI
needs:
- build
runs-on: ubuntu-latest
environment:
name: release-testpypi
url: https://test.pypi.org/p/entropy-data-cli
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/