-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #123 from vintasoftware/feat/release-publish
Release workflow
- Loading branch information
Showing
12 changed files
with
713 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ on: | |
- main | ||
- docs-update | ||
tags: | ||
- '**' | ||
- "**" | ||
|
||
env: | ||
COLUMNS: 150 | ||
|
@@ -51,15 +51,20 @@ jobs: | |
git config --global user.name "${{ github.actor }}" | ||
git config --global user.email "${{ github.actor }}@users.noreply.github.com" | ||
- run: poetry run mike deploy -b gh-pages dev --push | ||
if: "github.ref == 'refs/heads/main'" | ||
- name: Deploy on push to main | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
run: | | ||
poetry run mike deploy -b gh-pages dev --push | ||
- if: "github.ref == 'refs/heads/docs-update' || startsWith(github.ref, 'refs/tags/')" | ||
- name: Check version | ||
if: ${{ github.ref == 'refs/heads/docs-update' || startsWith(github.ref, 'refs/tags/') }} | ||
id: check-version | ||
uses: samuelcolvin/[email protected] | ||
with: | ||
version_file_path: 'django_ai_assistant/__init__.py' | ||
version_file_path: "django_ai_assistant/__init__.py" | ||
skip_env_check: true | ||
|
||
- run: poetry run mike deploy -b gh-pages ${{ steps.check-version.outputs.VERSION_MAJOR_MINOR }} latest --update-aliases --push | ||
if: "(github.ref == 'refs/heads/docs-update' || startsWith(github.ref, 'refs/tags/')) && !fromJSON(steps.check-version.outputs.IS_PRERELEASE)" | ||
- name: Deploy on push to docs-update branch or tag push | ||
if: ${{ (github.ref == 'refs/heads/docs-update' || startsWith(github.ref, 'refs/tags/')) && !fromJSON(steps.check-version.outputs.IS_PRERELEASE) }} | ||
run: | | ||
poetry run mike deploy -b gh-pages ${{ steps.check-version.outputs.VERSION_MAJOR_MINOR }} latest --update-aliases --push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: Publish packages (PyPI, npm) | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
publish-pypi: | ||
name: Publish django-ai-assistant to PyPI | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.12" | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install poetry | ||
poetry install --with dev --no-interaction | ||
- name: Build package | ||
run: | | ||
poetry build | ||
poetry run twine check dist/* | ||
- name: Publish package distributions to PyPI | ||
run: | | ||
poetry run twine upload dist/* | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | ||
|
||
publish-npm: | ||
name: Publish django-ai-assistant-client to npm | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20" | ||
registry-url: "https://registry.npmjs.org" | ||
|
||
- name: Install dependencies | ||
working-directory: ./frontend | ||
run: | | ||
npm install | ||
- name: Run ci | ||
working-directory: ./frontend | ||
run: | | ||
npm ci | ||
- name: Build package | ||
working-directory: ./frontend | ||
run: | | ||
npm run build | ||
- name: Publish package distributions to npm | ||
working-directory: ./frontend | ||
run: | | ||
npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Release draft creation | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: "Version of the release" | ||
required: true | ||
type: number | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
|
||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Extract changelog for version | ||
id: changelog | ||
run: | | ||
VERSION=${{ github.event.inputs.version }} | ||
# Extract changelog for version | ||
CHANGELOG=$(awk -v version="$VERSION" 'BEGIN{RS="## "; FS="\n"} $0 ~ version {print "## "$0}' CHANGELOG.md) | ||
# Remove the first line (version title) | ||
CHANGELOG=$(echo "$CHANGELOG" | sed '1d') | ||
# Verify if changelog was found | ||
if [ -z "$CHANGELOG" ]; then | ||
echo "Changelog for version $VERSION not found" | ||
exit 1 | ||
fi | ||
# Set output | ||
echo "CHANGELOG<<EOF" >> $GITHUB_ENV | ||
echo "$CHANGELOG" >> $GITHUB_ENV | ||
echo "EOF" >> $GITHUB_ENV | ||
- name: Print changelog | ||
run: | | ||
echo "Output is ${{ env.CHANGELOG }}" | ||
- name: Create GitHub Release Draft | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
tag_name: ${{ github.event.inputs.version }} | ||
name: ${{ github.event.inputs.version }} | ||
body: ${{ env.CHANGELOG }} | ||
draft: true | ||
prerelease: false | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Summary | ||
run: | | ||
echo "## 🚀 Release Summary" >> $GITHUB_STEP_SUMMARY | ||
echo "Release draft created for version ${{ github.event.inputs.version }}." >> $GITHUB_STEP_SUMMARY | ||
echo "Visit the [Releases section](https://github.com/vintasoftware/django-ai-assistant/releases) to review and publish the release." >> $GITHUB_STEP_SUMMARY | ||
echo "Once the draft is published, another action will automatically be triggered to publish the packages." >> $GITHUB_STEP_SUMMARY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Changelog | ||
|
||
This changelog references changes made both to the Django backend, `django-ai-assistant`, and the | ||
frontend TypeScript client, `django-ai-assistant-client`. | ||
|
||
|
||
!!! note | ||
The backend and the frontend are versioned together, that is, they have the same version number. | ||
When you update the backend, you should also update the frontend to the same version. | ||
|
||
## 0.0.1 <small>June 25, 2024</small> {id="0.0.1"} | ||
|
||
- Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../CHANGELOG.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.