Skip to content

correctly use github token from env #6

correctly use github token from env

correctly use github token from env #6

Workflow file for this run

name: Package, Tag and Release
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12' # Specify your Python version here
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
export PATH="$HOME/.local/bin:$PATH"
- name: Install Podman
run: |
sudo apt-get update
sudo apt-get -y install podman
- name: Install dependencies
run: poetry install
- name: Run your command with Poetry
run: poetry run crzd build
- name: Extract version from pyproject.toml
id: extract_version
run: |
VERSION=$(grep -E '^version\s*=' pyproject.toml | sed -E 's/version = "(.*)"/\1/')
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Create and push tag
env:
VERSION: ${{ env.VERSION }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "v$VERSION" -m "Version $VERSION"
git push -f origin "v$VERSION"
- name: Delete existing GitHub release if it exists
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ env.VERSION }}
run: |
gh auth login
if gh release view "v$VERSION" >/dev/null 2>&1; then
gh release delete "v$VERSION" -y
else
echo "Release for tag v$VERSION not found, skipping delete."
fi
- name: Create GitHub release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "v${{ env.VERSION }}"
release_name: "v${{ env.VERSION }}"
draft: false
prerelease: false
- name: Upload wheel file to release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/*.whl
asset_name: containerized_v${{ env.VERSION }}.whl
asset_content_type: application/octet-stream