This repository has been archived by the owner on Jul 11, 2024. It is now read-only.
Create Github Dev Release #17
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
name: Create Github Dev Release | |
on: | |
workflow_dispatch: | |
jobs: | |
release-dev-package: | |
timeout-minutes: 20 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ssh-key: ${{secrets.DEPLOY_KEY}} | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: 3.8 | |
- name: Ensure package version has 'dev' suffix | |
run: | | |
echo """ | |
import json, sys, os | |
SUFFIX = 'dev' | |
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}' | |
if SUFFIX not in version: | |
raise ValueError(f\"version {version} does not contain suffix {SUFFIX}\") | |
""" > /tmp/check1.py | |
python /tmp/check1.py | |
- 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 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build | |
- name: Build package | |
run: python setup.py build_py && python -m build | |
- name: Install the package and test it | |
run: | | |
# Install package | |
echo "Installing package..." | |
pip install ./dist/${{ github.event.repository.name }}-${{ steps.current-version.outputs.VERSION }}.tar.gz | |
- name: Extract commit hash | |
shell: bash | |
run: echo "##[set-output name=HASH;]$(echo $(git rev-parse HEAD))" | |
id: extract_hash | |
- name: Create/update release and tag | |
run: | | |
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 | |
- 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: | |
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 | |
- uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: Update version to ${{ steps.new-version.outputs.VERSION }} |