From 3a65f4bfe6017cc1fbd506cd96823b841640ac25 Mon Sep 17 00:00:00 2001 From: AmaseCocoa Date: Mon, 8 Jul 2024 23:32:40 +0900 Subject: [PATCH] Changed the way PyPI releases are created --- .github/workflows/upload.yml | 46 ++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/.github/workflows/upload.yml b/.github/workflows/upload.yml index 846ef92..8d99dc4 100644 --- a/.github/workflows/upload.yml +++ b/.github/workflows/upload.yml @@ -1,13 +1,9 @@ name: Pulblish to PyPI on: - release: - types: [released] - workflow_dispatch: - inputs: - version: - description: 'version' - required: true + push: + tags: + - "v*" jobs: release: @@ -15,21 +11,29 @@ jobs: 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<> $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: @@ -38,4 +42,4 @@ jobs: uses: pdm-project/setup-pdm@v4 - name: Publish to PyPI run: | - pdm publish \ No newline at end of file + PDM_BUILD_SCM_VERSION=${{ env.RELEASE_VERSION }} pdm publish \ No newline at end of file