Skip to content
This repository has been archived by the owner on Feb 8, 2025. It is now read-only.

Commit

Permalink
Changed the way PyPI releases are created
Browse files Browse the repository at this point in the history
  • Loading branch information
AmaseCocoa committed Jul 8, 2024
1 parent f51014f commit 3a65f4b
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions .github/workflows/upload.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@
name: Pulblish to PyPI

on:
release:
types: [released]
workflow_dispatch:
inputs:
version:
description: 'version'
required: true
push:
tags:
- "v*"

jobs:
release:
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: "Set env"
run: |
if [ -n "${{ github.event.inputs.version }}" ]; then
echo "RELEASE_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
git tag ${{ github.event.inputs.version }}
else
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
fi
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: echo version
- name: Get diff from CHANGELOG
run: |
echo $RELEASE_VERSION
echo ${{ env.RELEASE_VERSION }}
BEFORE=`git describe --tags v${GITHUB_REF#refs/*/v}^^`
echo 'CHANGELOG<<EOF' >> $GITHUB_ENV
git diff -u $BEFORE CHANGELOG.md | grep ^+ | grep -v ^+++ | sed s/^+// >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.RELEASE_VERSION }}
name: Release ${{ env.RELEASE_VERSION }}
body: ${{ env.CHANGELOG }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v5
with:
Expand All @@ -38,4 +42,4 @@ jobs:
uses: pdm-project/setup-pdm@v4
- name: Publish to PyPI
run: |
pdm publish
PDM_BUILD_SCM_VERSION=${{ env.RELEASE_VERSION }} pdm publish

0 comments on commit 3a65f4b

Please sign in to comment.