Skip to content

Commit

Permalink
Update release process (Avaiga#95)
Browse files Browse the repository at this point in the history
* Update release process

* Apply automatic changes

* update path

---------

Co-authored-by: dinhlongviolin1 <[email protected]>
  • Loading branch information
dinhlongviolin1 and dinhlongviolin1 authored Aug 3, 2023
1 parent d4d3e07 commit 81e97ef
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 253 deletions.
105 changes: 0 additions & 105 deletions .github/workflows/publish-dev.yml

This file was deleted.

63 changes: 25 additions & 38 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,77 +4,64 @@ on:
workflow_dispatch:
inputs:
version:
description: "The Pypi package version to create (ex: 1.0.0)"
description: "The tag of the package to publish on Pypi (ex: 1.0.0, 1.0.0.dev0)"
required: true

jobs:
test-package:
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: Extract Github Tag Version
id: vars
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT

- name: Ensure package version is properly set
run: |
echo """
import json, sys, os
with open(f\"src{os.sep}taipy{os.sep}config{os.sep}version.json\") as version_file:
version_o = json.load(version_file)
version_o = json.load(version_file)
version = f'{version_o.get(\"major\")}.{version_o.get(\"minor\")}.{version_o.get(\"patch\")}'
if vext := version_o.get(\"ext\"):
version = f'{version}.{vext}'
version = f'{version}.{vext}'
if version != sys.argv[1]:
raise ValueError(f\"Invalid version {version} / {sys.argv[1]}\")
""" > /tmp/check1.py
python /tmp/check1.py "${{ github.event.inputs.version }}"
- name: Validate branch name
run: |
echo """
import json, sys, os
with open(f\"src{os.sep}taipy{os.sep}config{os.sep}version.json\") as version_file:
version = json.load(version_file)
if f'release/{version.get(\"major\")}.{version.get(\"minor\")}' != sys.argv[1]:
raise ValueError(f'Branch name mismatch: release/{version.get(\"major\")}.{version.get(\"minor\")} != {sys.argv[1]}')
raise ValueError(f\"Invalid version {version} / {sys.argv[1]}\")
if sys.argv[1] != sys.argv[2]:
raise ValueError(f\"Invalid tag version {sys.argv[2]} with package version {sys.argv[1]}\")
""" > /tmp/check.py
python /tmp/check.py "${{ steps.extract_branch.outputs.branch }}"
python /tmp/check.py "${{ github.event.inputs.version }}" "${{ steps.vars.outputs.tag }}"
- name: Install dependencies
- name: Download assets from github release tag
run: |
python -m pip install --upgrade pip
pip install build
gh release download ${{ github.event.inputs.version }} --dir dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build and test the package
- name: Verify there is a release asset
run: |
python setup.py build_py && python -m build
pip install dist/*.tar.gz
if [ ! -f dist/${{ github.event.repository.name }}-${{ github.event.inputs.version }}.tar.gz ]; then
echo "No release asset found"
exit 1
publish-to-pypi:
needs: [test-package]
timeout-minutes: 20
environment: publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: actions/checkout@v3

- name: Install dependencies
- name: Download assets from tag
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python setup.py build_py && python -m build
gh release download ${{ github.event.inputs.version }} --dir dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Expand All @@ -91,7 +78,7 @@ jobs:
os: [ubuntu-latest,windows-latest,macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-versions }}
Expand Down
91 changes: 38 additions & 53 deletions .github/workflows/release-dev.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Create Github pre-release
name: Create Github Dev Release

on:
workflow_dispatch:

jobs:
publish:
release-dev-package:
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
Expand All @@ -16,21 +16,6 @@ jobs:
with:
python-version: 3.8

- name: Extract branch name
shell: bash
run: echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
id: extract_branch

- name: Validate branch name (has 'dev' prefix)
run: |
echo """
import sys
PREFIX = 'dev'
if not sys.argv[1].startswith(PREFIX):
raise ValueError(f'Branch name must start with \"{PREFIX}\"')
""" > /tmp/check.py
python /tmp/check.py "${{ steps.extract_branch.outputs.BRANCH }}"
- name: Ensure package version has 'dev' suffix
run: |
echo """
Expand All @@ -49,21 +34,21 @@ jobs:
- name: Grab the version of the package
id: current-version
run: |
echo """
import json, os
with open(f\"src{os.sep}taipy{os.sep}config{os.sep}version.json\") as version_file:
version_o = json.load(version_file)
version = f'{version_o.get(\"major\")}.{version_o.get(\"minor\")}.{version_o.get(\"patch\")}'
if vext := version_o.get(\"ext\"):
version = f'{version}.{vext}'
print(f'VERSION={version}')
""" > /tmp/check2.py
python /tmp/check2.py >> $GITHUB_OUTPUT
echo """
import json, os
with open(f\"src{os.sep}taipy{os.sep}config{os.sep}version.json\") as version_file:
version_o = json.load(version_file)
version = f'{version_o.get(\"major\")}.{version_o.get(\"minor\")}.{version_o.get(\"patch\")}'
if vext := version_o.get(\"ext\"):
version = f'{version}.{vext}'
print(f'VERSION={version}')
""" > /tmp/check2.py
python /tmp/check2.py >> $GITHUB_OUTPUT
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python setup.py build_py && python -m build
Expand All @@ -72,7 +57,7 @@ jobs:
run: |
# Install package
echo "Installing package..."
pip install ./dist/taipy-config-${{ steps.current-version.outputs.VERSION }}.tar.gz
pip install ./dist/${{ github.event.repository.name }}-${{ steps.current-version.outputs.VERSION }}.tar.gz
- name: Extract commit hash
shell: bash
Expand All @@ -81,39 +66,39 @@ jobs:

- name: Create/update release and tag
run: |
echo "Creating release ${{ steps.current-version.outputs.VERSION }}"
gh release create ${{ steps.current-version.outputs.VERSION }} ./dist/taipy-config-${{ steps.current-version.outputs.VERSION }}.tar.gz --target ${{ steps.extract_hash.outputs.HASH }} --prerelease --title ${{ steps.current-version.outputs.VERSION }} --notes "Dev Release ${{ steps.current-version.outputs.VERSION }}"
echo "Creating release ${{ steps.current-version.outputs.VERSION }}"
gh release create ${{ steps.current-version.outputs.VERSION }} ./dist/${{ github.event.repository.name }}-${{ steps.current-version.outputs.VERSION }}.tar.gz --target ${{ steps.extract_hash.outputs.HASH }} --prerelease --title ${{ steps.current-version.outputs.VERSION }} --notes "Dev Release ${{ steps.current-version.outputs.VERSION }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Reset changes
run: |
git reset --hard HEAD
git clean -fdx
git reset --hard HEAD
git clean -fdx
- name: Increase dev version
id: new-version
run: |
echo """
import json, os
with open(f'src{os.sep}taipy{os.sep}config{os.sep}version.json') as version_file:
echo """
import json, os
with open(f'src{os.sep}taipy{os.sep}config{os.sep}version.json') as version_file:
version_o = json.load(version_file)
if version_o is None or 'dev' not in version_o['ext']:
raise ValueError('Invalid version file. Version must contain dev suffix.')
prev_version = version_o['ext']
new_version = 'dev' + str(int(version_o['ext'].replace('dev', '')) + 1)
with open(f'src{os.sep}taipy{os.sep}config{os.sep}version.json') as r:
text = r.read().replace(prev_version, new_version)
with open(f'src{os.sep}taipy{os.sep}config{os.sep}version.json', mode='w') as w:
w.write(text)
with open(f\"src{os.sep}taipy{os.sep}config{os.sep}version.json\") as version_file:
version_o = json.load(version_file)
if version_o is None or 'dev' not in version_o['ext']:
raise ValueError('Invalid version file. Version must contain dev suffix.')
prev_version = version_o['ext']
new_version = 'dev' + str(int(version_o['ext'].replace('dev', '')) + 1)
with open(f'src{os.sep}taipy{os.sep}config{os.sep}version.json') as r:
text = r.read().replace(prev_version, new_version)
with open(f'src{os.sep}taipy{os.sep}config{os.sep}version.json', mode='w') as w:
w.write(text)
with open(f\"src{os.sep}taipy{os.sep}config{os.sep}version.json\") as version_file:
version_o = json.load(version_file)
version = f'{version_o.get(\"major\")}.{version_o.get(\"minor\")}.{version_o.get(\"patch\")}'
if vext := version_o.get(\"ext\"):
version = f'{version}.{vext}'
print(f'VERSION={version}')
""" > /tmp/increase_dev_version.py
python /tmp/increase_dev_version.py >> $GITHUB_OUTPUT
version = f'{version_o.get(\"major\")}.{version_o.get(\"minor\")}.{version_o.get(\"patch\")}'
if vext := version_o.get(\"ext\"):
version = f'{version}.{vext}'
print(f'VERSION={version}')
""" > /tmp/increase_dev_version.py
python /tmp/increase_dev_version.py >> $GITHUB_OUTPUT
- uses: stefanzweifel/git-auto-commit-action@v4
with:
Expand Down
Loading

0 comments on commit 81e97ef

Please sign in to comment.