Skip to content

feat: add 15 more leetcodes (#74) #65

feat: add 15 more leetcodes (#74)

feat: add 15 more leetcodes (#74) #65

Workflow file for this run

name: cd
on:
push:
branches:
- main
permissions:
contents: write
issues: write
pull-requests: write
jobs:
versioning:
name: versioning
runs-on: ubuntu-latest
outputs:
new_release_version: ${{ steps.set-outputs.outputs.version }}
new_release_published: ${{ steps.set-outputs.outputs.published }}
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0
- name: Check existing release
id: check-release
run: |
CURRENT_SHA=$(git rev-parse HEAD)
EXISTING_TAG=$(git tag --points-at $CURRENT_SHA | grep '^v' | head -1)
if [ -n "$EXISTING_TAG" ]; then
echo "existing_tag=$EXISTING_TAG" >> $GITHUB_OUTPUT
echo "existing_version=${EXISTING_TAG#v}" >> $GITHUB_OUTPUT
echo "has_existing=true" >> $GITHUB_OUTPUT
else
echo "has_existing=false" >> $GITHUB_OUTPUT
fi
- id: release
name: Release
if: steps.check-release.outputs.has_existing == 'false'
uses: cycjimmy/semantic-release-action@9cc899c47e6841430bbaedb43de1560a568dfd16 # v5.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set outputs
id: set-outputs
run: |
if [ "${{ steps.check-release.outputs.has_existing }}" == "true" ]; then
echo "version=${{ steps.check-release.outputs.existing_version }}" >> $GITHUB_OUTPUT
echo "published=true" >> $GITHUB_OUTPUT
echo "Using existing release: ${{ steps.check-release.outputs.existing_version }}"
else
echo "version=${{ steps.release.outputs.new_release_version }}" >> $GITHUB_OUTPUT
echo "published=${{ steps.release.outputs.new_release_published }}" >> $GITHUB_OUTPUT
echo "New release: ${{ steps.release.outputs.new_release_version }}"
fi
publish:
name: publish to pypi
runs-on: ubuntu-latest
needs: versioning
if: needs.versioning.outputs.new_release_published == 'true'
environment:
name: pypi
url: https://pypi.org/p/leetcode-py
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Set up Python
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: "3.13"
- name: Install Poetry
uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1.4.1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true
- name: Update version in pyproject.toml
run: |
poetry version ${{ needs.versioning.outputs.new_release_version }}
- name: Build package
run: poetry build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
with:
verbose: true