-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
66 additions
and
0 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,43 @@ | ||
name: Automatic release | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 0 1 */3 *' | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set git user | ||
uses: fregante/setup-git-user@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: 3.x | ||
|
||
- name: Update repository for release | ||
id: update | ||
run: echo "version=$(python update_for_release.py)" >> "$GITHUB_OUTPUT" # returns new version to output | ||
|
||
- name: Commit changes | ||
run: | | ||
git add plugin.json | ||
git commit -m "Update for release ${{ steps.update.outputs.version }}" | ||
- name: Push changes and tags | ||
run: | | ||
git push origin HEAD | ||
git push origin --tags | ||
- name: Create release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
name: Release ${{ steps.update.outputs.version }} | ||
body: "Automatic release" | ||
tag_name: v${{ steps.update.outputs.version }} |
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,23 @@ | ||
import json | ||
import time | ||
from pathlib import Path | ||
|
||
if __name__ == "__main__": | ||
release_path = Path("plugin.json") | ||
with release_path.open("r") as file: | ||
data = json.load(file) | ||
|
||
old_version: str = data["version"] | ||
new_version = time.strftime("%Y-%m-%d") | ||
|
||
if old_version.startswith(new_version): | ||
patch = int(old_version[index + 1 :]) if (index := old_version.rfind(".")) != -1 else 0 | ||
new_version += f".{patch + 1}" | ||
|
||
data["version"] = new_version | ||
|
||
with release_path.open("w") as file: | ||
json.dump(data, file, indent=4) | ||
|
||
# Print new version so the github action can use it | ||
print(new_version) |