-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvements to CI and Release workflow (#18)
* Remove stale import * Add Version Bump Script and package.json * Update used CI Scripts to latest version * Change Actions Version to main version without typing the minor version * Add Version Bump Workflow * Add Draft Release workflow Add release.yml for templating release notes
- Loading branch information
Showing
9 changed files
with
213 additions
and
5 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
changelog: | ||
categories: | ||
- title: ⚠️ Breaking Changes | ||
labels: | ||
- breaking-change | ||
|
||
- title: 🖥️ Web | ||
labels: | ||
- web | ||
|
||
- title: 🐍 Python | ||
labels: | ||
- python | ||
|
||
- title: ⚡ API | ||
labels: | ||
- api | ||
|
||
- title: 📓 Documentation | ||
labels: | ||
- documentation | ||
|
||
- title: 🔨 Maintenance | ||
labels: | ||
- deployment | ||
- dependencies | ||
- renovate | ||
- maintenance | ||
- tech-debt | ||
|
||
- title: Other changes | ||
labels: | ||
- "*" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Bump Version and Commit to main | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
serverBump: | ||
description: 'Bump Script Version' | ||
required: true | ||
default: 'false' | ||
type: choice | ||
options: | ||
- 'False' | ||
- minor | ||
- patch | ||
- major | ||
|
||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }}-root | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
bump_version: | ||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
ref: ${{ steps.push-tag.outputs.commit_long_sha }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | ||
|
||
- name: setup python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12' # install the python version needed | ||
|
||
- name: install python packages | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Bump version | ||
run: python test.py --server="${{ inputs.serverBump }}" | ||
|
||
- name: Commit and tag | ||
id: push-tag | ||
uses: EndBug/add-and-commit@v9 | ||
with: | ||
author_name: Simon_Bot | ||
message: 'Version ${{ env.NEXT_SERVER }}' | ||
tag: ${{ env.NEXT_SERVER }} | ||
push: true |
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Prepare new draft release | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }}-root | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
prepare_release: | ||
runs-on: ubuntu-latest | ||
needs: build_mobile | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create draft release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
draft: true | ||
tag_name: ${{ env.NEXT_SERVER }} | ||
generate_release_notes: true | ||
# body_path: misc/release/notes.tmpl |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import json | ||
import argparse | ||
import os | ||
|
||
|
||
def get_current_version(file: str = "package.json") -> tuple[str, str, str]: | ||
""" | ||
This reads a json file and return the current version from the field 'version' | ||
:param file: input a json file which has the key 'data' | ||
:return: returns major, minor and patch version as a tuple of strings | ||
""" | ||
# print(f'Reading current version from file {file}') | ||
with open(file, 'r') as f: | ||
data = json.load(f) | ||
major, minor, patch = data['version'].split(".") | ||
|
||
return major, minor, patch | ||
|
||
|
||
def print_current_version(major: str, minor: str, patch: str) -> None: | ||
print(f"Current Version: {major}.{minor}.{patch}") | ||
|
||
|
||
def print_next_version(major: str, minor: str, patch: str) -> None: | ||
print(f"Next Version: {major}.{minor}.{patch}") | ||
|
||
|
||
def parse_version_bump(): | ||
parser = argparse.ArgumentParser(description="Script that adds 3 numbers from CMD") | ||
parser.add_argument("--server", "-s", required=False, type=str) | ||
args = parser.parse_args() | ||
|
||
if args.server == "major": | ||
return "major" | ||
elif args.server == "minor": | ||
return "minor" | ||
elif args.server == "patch": | ||
return "patch" | ||
elif args.server == "False": | ||
return "None" | ||
else: | ||
return "None" | ||
|
||
|
||
def bump_version(current_major: str, current_minor: str, current_patch: str, bump: str) -> tuple[str, str, str]: | ||
next_major = current_major | ||
next_minor = current_minor | ||
next_patch = current_patch | ||
if bump == "major": | ||
next_major = str(int(next_major) + 1) | ||
elif bump == "minor": | ||
next_minor = str(int(next_minor) + 1) | ||
elif bump == "patch": | ||
next_patch = str(int(next_patch) + 1) | ||
elif bump == "False": | ||
pass | ||
|
||
return next_major, next_minor, next_patch | ||
|
||
|
||
def update_json_file(next_major: str, next_minor: str, next_patch: str, file: str = "package.json"): | ||
with open(file, 'r') as f: | ||
data = json.load(f) | ||
f.close() | ||
data['version'] = f"{next_major}.{next_minor}.{next_patch}" | ||
with open(file, 'w') as f: | ||
json_object = json.dumps(data, indent=4) | ||
f.write(json_object) | ||
f.close() | ||
print("Updated Version") | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
major, minor, patch = get_current_version() | ||
print_current_version(major, minor, patch) | ||
bump = parse_version_bump() | ||
next_major, next_minor, next_patch = bump_version(major, minor, patch, bump) | ||
print_next_version(next_major, next_minor, next_patch) | ||
update_json_file(next_major, next_minor, next_patch) | ||
|
||
if os.getenv("GITHUB_ACTIONS") == "true": | ||
import os | ||
|
||
env_file = os.getenv('GITHUB_ENV') | ||
|
||
with open(env_file, "a") as myfile: | ||
myfile.write(f"NEXT_SERVER={next_major}.{next_minor}.{next_patch}") |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "dns-owl", | ||
"version": "0.3.1" | ||
} |