diff --git a/.github/workflows/do_release.yaml b/.github/workflows/do_release.yaml new file mode 100644 index 0000000000..76f37c8d10 --- /dev/null +++ b/.github/workflows/do_release.yaml @@ -0,0 +1,60 @@ +name: Publish a new release + +on: + workflow_dispatch: + inputs: + target: + description: Which kind of release is this? + required: true + type: choice + default: "stable" + options: + - "master" + - "stable" + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v2 + - name: Set up environment + run: pip install requests >/dev/null 2>&1 + - name: Gather version information + id: version + env: + TARGET: ${{ github.event.inputs.target }} + run: python3 ci/version_check.py do_release + - name: Gather auto-text + id: auto_text + run: | + auto_text = curl -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: ${{ secrets.GITHUB_TOKEN }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/inventree/InvenTree/releases/generate-notes \ + -d '{"tag_name":"${{ steps.version.outputs.tag }}","target_commitish":"${{ github.event.inputs.target }}","previous_tag_name":"${{ steps.version.outputs.old_version }}}","configuration_file_path":".github/release.yml"}' + echo $auto_text + echo "auto_text=$auto_text" >> $GITHUB_OUTPUT + - name: "Dummy: Set version" + run: echo "Change version to ${{ steps.version.outputs.tag }}" + - name: "Dummy: Update changelog header" + id: changelog + run: | + echo "Update changelog to ${{ steps.version.outputs.tag }}" + echo "changelog_text=$(grep 'version' setup.py | cut -d "'" -f 2)" >> $GITHUB_OUTPUT + - name: "Dummy: Push changes" + run: echo "Push changes to ${{ github.event.inputs.target }}" + - name: "Dummy: Create release" + run: | + echo "Creating release for ${{ steps.version.outputs.tag }} on branch ${{ github.event.inputs.target }}" + echo "Branch text: + ${{ steps.changelog.outputs.changelog_text }} + + ${{ steps.auto_text.outputs.auto_text }}" + - name: "Dummy: Bumpy version on master" + if: github.event.inputs.target == 'master' + run: echo "Bumping version on master to ${{ steps.version.outputs.new_tag }}" diff --git a/ci/version_check.py b/ci/version_check.py index a46236508a..a3c28fba76 100644 --- a/ci/version_check.py +++ b/ci/version_check.py @@ -97,6 +97,25 @@ if __name__ == '__main__': results = re.findall(r"""INVENTREE_API_VERSION = (.*)""", text) print(results[0]) exit(0) + + if 'do_release' in sys.argv: + target = os.getenv('TARGET') + highest_tupple = get_existing_release_tags()[0] + + old_version = f'{highest_tupple[0]}.{highest_tupple[1]}.{highest_tupple[2]}' + if target == 'master': + tag = f'{highest_tupple[0]}.{highest_tupple[1] + 1}.0' + elif target == 'stable': + tag = f'{highest_tupple[0]}.{highest_tupple[1]}.{highest_tupple[2] + 1}' + else: + raise ValueError(f"Unknown target '{target}'") + new_tag = f'{tag} dev' + + with open(os.getenv('GITHUB_OUTPUT'), 'a') as env_file: + env_file.write(f'old_version={old_version}\n') + env_file.write(f'tag={tag}\n') + env_file.write(f'new_tag={new_tag}\n') + exit(0) # GITHUB_REF_TYPE may be either 'branch' or 'tag' GITHUB_REF_TYPE = os.environ['GITHUB_REF_TYPE']