Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Changelog in repo + autorelease #6593

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add release workflow dummy
matmair committed Feb 29, 2024
commit 944c55c583db1bec52affc16ee824c9c339a0a35
60 changes: 60 additions & 0 deletions .github/workflows/do_release.yaml
Original file line number Diff line number Diff line change
@@ -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 }}"
19 changes: 19 additions & 0 deletions ci/version_check.py
Original file line number Diff line number Diff line change
@@ -97,6 +97,25 @@ def check_version_number(version_string, allow_duplicate=False):
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']