This repository has been archived by the owner on Jul 11, 2024. It is now read-only.
Create Github Release #26
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 Release | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "The release/package version to create (ex: 1.0.0)" | |
required: true | |
jobs: | |
release-package: | |
timeout-minutes: 20 | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
actions: write | |
steps: | |
- 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: 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 = f'{version_o.get(\"major\")}.{version_o.get(\"minor\")}.{version_o.get(\"patch\")}' | |
if vext := version_o.get(\"ext\"): | |
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]}') | |
""" > /tmp/check2.py | |
python /tmp/check2.py "${{ steps.extract_branch.outputs.branch }}" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build | |
- name: Build and test the package | |
run: | | |
python setup.py build_py && python -m build | |
pip install dist/*.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: | | |
gh release create ${{ github.event.inputs.version }} ./dist/${{ github.event.repository.name }}-${{ github.event.inputs.version }}.tar.gz --target ${{ steps.extract_hash.outputs.hash }} --title ${{ github.event.inputs.version }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |