Skip to content

Commit

Permalink
Publish action (#35)
Browse files Browse the repository at this point in the history
## Description

Automatically deploy Docker image, pip package, docs after publishing
releases.

## Impact on users using Chronovoyage

Active update of the app.
  • Loading branch information
noritakaIzumi authored Nov 4, 2024
1 parent 60f3463 commit 207585d
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 23 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/publish-docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
name: Publish Docker image

on:
workflow_dispatch:
workflow_call:
inputs:
tag:
type: string
required: true

env:
REGISTRY: ghcr.io
Expand Down Expand Up @@ -36,6 +40,10 @@ jobs:
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=true
tags: |
type=raw,value=${{ inputs.tag }}
- name: Build and push Docker image
id: push
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
name: Build documentation
name: Publish documentation

on:
workflow_dispatch:

permissions:
id-token: write
contents: read
workflow_call:

env:
INSTANCE: 'Writerside/cd'
Expand Down Expand Up @@ -55,7 +51,10 @@ jobs:
deploy:
env:
AWS_REGION: 'us-east-1'
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
BRANCH_NAME: main
permissions:
contents: read
id-token: write
needs:
- build
- test
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/publish-pip-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Publish Pip Package

on:
workflow_call:
inputs:
tag:
type: string
required: true

env:
app-name: "chronovoyage"

jobs:
main:
runs-on: ubuntu-latest
environment: release
permissions:
contents: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Download assets
uses: robinraju/release-downloader@v1
with:
tag: ${{ inputs.tag }}
fileName: ${{ env.app-name }}-*
out-file-path: dist

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
47 changes: 32 additions & 15 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,43 @@
name: Publish to PyPI

on:
workflow_dispatch:
release:
types:
- published

permissions:
contents: read
env:
app-name: "chronovoyage"

jobs:
publish:
check-tag-name-exists:
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
if: ${{ github.event.release.tag_name != '' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- run: "true"

- name: Install Hatch
uses: pypa/hatch@install
publish-pip-package:
needs: check-tag-name-exists
uses: ./.github/workflows/publish-pip-package.yml
with:
tag: ${{ github.event.release.tag_name }}
permissions:
contents: read
id-token: write

- name: Build Package
run: hatch build -c
publish-docker-image:
needs: check-tag-name-exists
uses: ./.github/workflows/publish-docker-image.yml
with:
tag: ${{ github.event.release.tag_name }}
permissions:
contents: read
packages: write
attestations: write
id-token: write

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
publish-docs:
needs: check-tag-name-exists
uses: ./.github/workflows/publish-docs.yml
permissions:
contents: read
id-token: write

0 comments on commit 207585d

Please sign in to comment.