Skip to content

ci: update release.yml fix checkout problem #4

ci: update release.yml fix checkout problem

ci: update release.yml fix checkout problem #4

Workflow file for this run

name: Deploy
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3
- name: Install dependencies
run: |
pip install hatch twine
- name: Set DATE variable
run: echo "DATE=$(date +%Y.%-m.%-d)" >> $GITHUB_ENV
- name: Display date
run: echo "date ${{ env.DATE }}"
- name: Set initial TAG_NUMBER
run: echo "TAG_NUMBER=1" >> $GITHUB_ENV
- name: Get last tag
id: get_last_tag
run: echo "LAST_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
- name: Display last tag
run: echo "last tag ${{ env.LAST_TAG }}"
- name: Determine new tag
id: determine_tag
run: |
# Determine if the last tag was created today
if [[ "${{ env.LAST_TAG }}" == *"${{ env.DATE }}"* ]]; then
TAG_NUMBER=$(echo "${{ env.LAST_TAG }}" | awk -F. '{print $NF}')
TAG_NUMBER=$((TAG_NUMBER + 1))
else
TAG_NUMBER=1
fi
NEW_TAG="${{ env.DATE }}.${TAG_NUMBER}"
echo "NEW_TAG=${NEW_TAG}" >> $GITHUB_ENV
echo "TAG_NUMBER=${TAG_NUMBER}" >> $GITHUB_ENV
- name: Display new tag
run: echo "Creating tag ${{ env.NEW_TAG }}"
- name: Create and push tag
run: |
git tag "${{ env.NEW_TAG }}"
git push origin "${{ env.NEW_TAG }}"
- name: Update version with hatch
run: hatch version ${{ env.NEW_TAG }}
- name: Build with hatch
run: hatch build
- name: Upload to PyPI
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
run: twine upload dist/*