Skip to content

Commit

Permalink
Merge pull request #4 from farmisen/farmisen/upy-5-fix-publish-and-re…
Browse files Browse the repository at this point in the history
…lease-github-action

[UPY-5] iFx publish and release github action
  • Loading branch information
farmisen authored Feb 12, 2025
2 parents b757351 + 04aa24d commit b3cb4ee
Showing 1 changed file with 57 additions and 52 deletions.
109 changes: 57 additions & 52 deletions .github/workflows/publish_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,59 +12,64 @@ on:
- minor
- major

permissions:
contents: write

jobs:
publish_and_release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"

- name: Install Poetry
run: |
curl -sSL "https://install.python-poetry.org" | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Configure Git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
- name: Bump version
run: poetry version ${{ github.event.inputs.bump_type }}

- name: Get new version
id: get_version
run: echo "new_version=$(poetry version -s)" >> $GITHUB_OUTPUT

- name: Build package
run: poetry build

- name: Publish to PyPI
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
run: poetry publish

- name: Commit changes
run: |
git config --global user.name 'Fabrice Armisen'
git config --global user.email 'farmisen@gmail.com'
git add pyproject.toml
git commit -m "Release v${{ steps.get_version.outputs.new_version }}"
git tag "v${{ steps.get_version.outputs.new_version }}"
git push
git push --tags
- name: Create Release
uses: elgohr/Github-Release-Action@v5
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
title: "v${{ steps.get_version.outputs.new_version }}"
tag: "v${{ steps.get_version.outputs.new_version }}"
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"

- name: Install Poetry
run: |
curl -sSL "https://install.python-poetry.org" | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Bump version
run: poetry version ${{ github.event.inputs.bump_type }}

- name: Get new version
id: get_version
run: echo "new_version=$(poetry version -s)" >> $GITHUB_OUTPUT

- name: Build package
run: poetry build

- name: Publish to PyPI
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
run: poetry publish

- name: Commit changes
run: |
# Configure git with your user details
git config --global user.name 'Fabrice Armisen'
git config --global user.email 'farmisen@gmail.com'
# Stage and commit the version bump in pyproject.toml
git add pyproject.toml
git commit -m "Release v${{ steps.get_version.outputs.new_version }}"
# Create a tag for the new version
git tag "v${{ steps.get_version.outputs.new_version }}"
# Reset remote URL with GitHub token for pushing the changes
git remote set-url origin \
https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/farmisen/upyloadthing.git
# Push commit and tags
git push
git push --tags
- name: Create Release
uses: elgohr/Github-Release-Action@v5
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
title: "v${{ steps.get_version.outputs.new_version }}"
tag: "v${{ steps.get_version.outputs.new_version }}"

0 comments on commit b3cb4ee

Please sign in to comment.