Skip to content

Commit

Permalink
Fix create new release (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
noritakaIzumi authored Nov 4, 2024
1 parent 7aedf09 commit 0a3a6a2
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 15 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/build-pip-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build pip package

on:
workflow_call:
inputs:
version:
description: Version string from hatch
type: string
required: true

env:
app-name: "chronovoyage"

jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Hatch
uses: pypa/hatch@install

- name: Build Package
run: hatch build -c

- name: Upload artifacts (sdist)
uses: actions/upload-artifact@v4
with:
name: pip-package--sdist
path: dist/${{ env.app-name }}-${{ inputs.version }}.tar.gz

- name: Upload artifacts (wheel)
uses: actions/upload-artifact@v4
with:
name: pip-package--wheel
path: dist/${{ env.app-name }}-${{ inputs.version }}-py3-none-any.whl
46 changes: 37 additions & 9 deletions .github/workflows/create-new-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@ on:
types:
- closed

env:
tag-prefix: "v"

jobs:
push-tag:
name: Push a tag
if: ${{ contains(github.event.pull_request.labels.*.name, 'new release') && github.event.pull_request.merged }}
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
tag: ${{ steps.tag.outputs.value }}
version: ${{ steps.tag.outputs.version }}
tag: ${{ steps.tag.outputs.tag }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -28,22 +35,43 @@ jobs:
- name: Push a tag
id: tag
run: |
tag="v$(hatch version)"
version="$(hatch version)"
tag="${{ env.tag-prefix }}${version}"
git tag -a ${tag} -m "New release ${tag} (tagged by github-actions[bot])"
git push origin ${tag}
echo "value=${tag}" >> $GITHUB_OUTPUT
echo "version=${version}" >> $GITHUB_OUTPUT
echo "tag=${tag}" >> $GITHUB_OUTPUT
build-package:
needs:
- push-tag
uses: ./.github/workflows/build-pip-package.yml
with:
version: ${{ needs.push-tag.outputs.version }}

create-release:
name: Create a release
runs-on: ubuntu-latest
needs: push-tag
needs:
- push-tag
- build-package
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
pattern: pip-package--*
merge-multiple: true

- name: Create a release
uses: elgohr/Github-Release-Action@v5
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: softprops/action-gh-release@v2
with:
title: ${{ steps.tag.outputs.value }}
tag: ${{ steps.tag.outputs.value }}
draft: true
tag_name: ${{ needs.push-tag.outputs.tag }}
generate_release_notes: true
files: dist/*
5 changes: 0 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,8 @@ permissions:
contents: read

jobs:
test:
uses: ./.github/workflows/test.yml

publish:
runs-on: ubuntu-latest
needs:
- test
environment: release
permissions:
id-token: write
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
pull_request:
branches:
- main
workflow_call:
workflow_dispatch:

concurrency:
Expand Down

0 comments on commit 0a3a6a2

Please sign in to comment.