mirror of
https://github.com/bombsquad-community/plugin-manager.git
synced 2025-10-08 14:54:36 +00:00
Updated actiont to run on commit
This commit is contained in:
parent
a30d298e20
commit
281459cac1
4 changed files with 86 additions and 32 deletions
68
.github/workflows/release.yml
vendored
68
.github/workflows/release.yml
vendored
|
|
@ -2,44 +2,56 @@ name: Create Release
|
|||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- v1.*
|
||||
paths:
|
||||
- index.json
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Create Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.11'
|
||||
- run: |
|
||||
output=$(python3 test/get_changes.py "${{ github.ref }}")
|
||||
echo "::set-output name=changelog::$output"
|
||||
id: set_changelog
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
|
||||
|
||||
- name: 'Get Previous tag'
|
||||
uses: oprypin/find-latest-tag@v1.1.2
|
||||
with:
|
||||
tag_name: ${{ github.ref }}
|
||||
release_name: ${{ github.ref }}
|
||||
repository: ${{ github.repository }}
|
||||
releases-only: true # We know that all relevant tags have a GitHub release for them.
|
||||
id: previoustag
|
||||
|
||||
- name: set_variables
|
||||
run: |
|
||||
output1=$(python3 test/get_latest.py)
|
||||
output2=$(python3 test/get_changes.py "$output1")
|
||||
output3=$(python3 test/version_is_lower.py ${{ steps.previoustag.outputs.tag }})
|
||||
echo "latestVersion=$output1" >> $GITHUB_OUTPUT
|
||||
echo "changelog=$output2" >> $GITHUB_OUTPUT
|
||||
echo "shouldRun=$output3" >> $GITHUB_OUTPUT
|
||||
id: set_variables
|
||||
|
||||
|
||||
|
||||
- name: Bump version and push tag
|
||||
if: ${{ steps.set_variables.outputs.shouldRun == '1' }}
|
||||
id: tag_version
|
||||
uses: mathieudutour/github-tag-action@v6.2
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
custom_tag: |
|
||||
${{ steps.set_variables.outputs.latestVersion }}
|
||||
|
||||
- name: Create release
|
||||
if: ${{ steps.tag_version.outputs.new_tag }}
|
||||
uses: ncipollo/release-action@v1
|
||||
with:
|
||||
tag: ${{ steps.tag_version.outputs.new_tag }}
|
||||
name: Release ${{ steps.tag_version.outputs.new_tag }}
|
||||
artifacts: "plugin_manager.py"
|
||||
body: |
|
||||
## Changelog
|
||||
${{ steps.set_changelog.outputs.changelog }}
|
||||
draft: false
|
||||
prerelease: false\
|
||||
- name: Upload Release Asset
|
||||
id: upload-release-asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
|
||||
asset_path: ./plugin_manager.py
|
||||
asset_name: plugin_manager.py
|
||||
asset_content_type: application
|
||||
${{ steps.set_variables.outputs.changelog }}
|
||||
|
||||
|
|
@ -2,7 +2,7 @@ import re
|
|||
import sys
|
||||
|
||||
|
||||
def get_version_changelog(version):
|
||||
def get_version_changelog(version: str):
|
||||
with open('CHANGELOG.md', 'r') as file:
|
||||
content = file.read()
|
||||
pattern = rf"### {version} \(\d\d-\d\d-\d{{4}}\)\n(.*?)(?=### \d+\.\d+\.\d+|\Z)"
|
||||
|
|
@ -15,10 +15,9 @@ def get_version_changelog(version):
|
|||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: python3 script.py version_number")
|
||||
print(f"Usage: python3 {__file__.split('/')[-1]} version_number")
|
||||
sys.exit(1)
|
||||
|
||||
version = sys.argv[1].replace("refs/tags/", "")
|
||||
version = version.replace("v", "", 1)
|
||||
version = sys.argv[1].replace("v", "", 1)
|
||||
changelog = get_version_changelog(version)
|
||||
print(changelog)
|
||||
|
|
|
|||
12
test/get_latest.py
Normal file
12
test/get_latest.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import json
|
||||
|
||||
|
||||
def get_latest():
|
||||
with open('index.json', 'r') as file:
|
||||
content = json.loads(file.read())
|
||||
latest_version = list(content["versions"].keys())[0]
|
||||
return latest_version
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(get_latest())
|
||||
31
test/version_is_lower.py
Normal file
31
test/version_is_lower.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import sys
|
||||
from get_latest import get_latest
|
||||
|
||||
|
||||
def semantic_to_str(semantic_version: str):
|
||||
out = ""
|
||||
for i in (semantic_version.split(".")):
|
||||
if len(i) == 1:
|
||||
out += "00"+i
|
||||
if len(i) == 2:
|
||||
out += "0"+i
|
||||
return out
|
||||
|
||||
|
||||
def version_is_lower(version: str):
|
||||
latest = semantic_to_str(get_latest())
|
||||
version = semantic_to_str(version)
|
||||
if latest > version:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
print(f"Usage: python3 {__file__.split('/')[-1]} version_number")
|
||||
sys.exit(1)
|
||||
|
||||
version = sys.argv[1].replace("v", "", 1)
|
||||
out = version_is_lower(version)
|
||||
print(int(out))
|
||||
Loading…
Add table
Add a link
Reference in a new issue