Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
44 changes: 44 additions & 0 deletions .github/notify_published.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import re
import requests
import simplejson as json
import sys

is_dev = len(sys.argv) >= 3 and bool(sys.argv[2])
search_string = \
r'Uploaded to (magemonkey-repo): (https:\/\/repo\.travja\.dev(:443)?\/.*?\/studio\/magemonkey\/(.*?)\/(.*?)\/(' \
r'.*?)(?<!sources|javadoc)\.jar(?!\.asc)) '

def get_info():
with open('log.txt', 'r') as file:
content = file.read()
content = re.sub(r'\x1B\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]', '', content) # Remove ANSI escape codes
data = re.findall(search_string, content, re.MULTILINE)
found_version = data[0][5]
artifact_id = data[0][3]
artifact_url = data[0][1]
return found_version, artifact_id, artifact_url


version, name, url = get_info()
if is_dev:
split = version.split('-')[0:-2]
version = '-'.join(split)
embed = {
'username': 'Dev Mage',
'author': {
'name': 'New ' + ('Dev ' if is_dev else '') + 'Build Available!',
'url': 'https://github.com/magemonkeystudio/' + name
},
'image': {
'url': 'https://fabled.magemonkey.studio/' + ('dev_build.gif' if is_dev else 'release_build.gif')
},
'title': version,
'description': 'Click the link above to download the new build!',
'url': url,
'color': 5341129
}

requests.post(sys.argv[1],
headers={'Content-Type': 'application/json'},
data=json.dumps({'embeds': [embed]})
)
26 changes: 26 additions & 0 deletions .github/update_readme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import sys

is_dev = len(sys.argv) >= 2 and bool(sys.argv[1])
remove = '''<repository>
<id>magemonkey-snapshots</id>
<url>https://repo.travja.dev/snapshots</url>
</repository>
...
'''

replace = '''<repository>
<id>magemonkey-releases</id>
<url>https://repo.travja.dev/releases</url>
</repository>
...
'''


def replace_repository():
with open('README.md', 'r') as readme:
contents = readme.read().replace(remove, replace)
with open('README.md', 'w') as readme:
readme.write(contents)


replace_repository()
40 changes: 40 additions & 0 deletions .github/update_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import re
import sys

is_dev = len(sys.argv) >= 2 and eval(sys.argv[1].lower().capitalize())
prep = not is_dev and len(sys.argv) >= 3 and bool(sys.argv[2])


def replace_version():
regex = r'^[ ]{4}<version>((((\d+\.?)+)((-R(\d+)\.?)(\d+)?)?)(-SNAPSHOT)?)<\/version>$'
with open('pom.xml', 'r') as pom:
contents = pom.read()
ver = re.findall(regex, contents, re.MULTILINE)
version = ver[0][0]
bare_version = ver[0][2]
if is_dev:
if not '-R' in version:
new_version = version + '-R0.1-SNAPSHOT'
elif not '-SNAPSHOT' in version:
new_version = version + '.1-SNAPSHOT'
else:
r_version = ver[0][5]
patch = int(ver[0][7]) + 1
new_version = bare_version + r_version + str(patch) + '-SNAPSHOT'
elif prep:
r_version = int(ver[0][6]) + 1
new_version = bare_version + '-R' + str(r_version)
else:
version = ver[0][2]
minor = int(ver[0][3])
new_version = version[:-(len(str(minor)))] + str(minor + 1)
contents = re.sub(regex,
' <version>' + new_version + '</version>',
contents,
1,
re.MULTILINE)
with open('pom.xml', 'w') as pom:
pom.write(contents)


replace_version()
24 changes: 20 additions & 4 deletions .github/workflows/dependabot-autoapprove.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
name: Dependabot auto-approve
on: pull_request_target

permissions:
pull-requests: write
jobs:
dependabot:
uses: magemonkeystudio/.github/.github/workflows/reusable-dependabot-autoapprove.yml@main
secrets: inherit

runs-on: ubuntu-latest
# Checking the author will prevent your Action run failing on non-Dependabot PRs
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: dependabot-metadata
uses: dependabot/fetch-metadata@v1
- uses: actions/checkout@v4
- name: Approve a PR if not already approved
run: |
gh pr checkout "$PR_URL" # sets the upstream metadata for `gh pr status`
if [ "$(gh pr status --json reviewDecision -q .currentBranch.reviewDecision)" != "APPROVED" ];
then gh pr review --approve "$PR_URL"
else echo "PR already approved, skipping additional approvals to minimize emails/notification noise.";
fi
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.ACTIONS_PAT}}
18 changes: 14 additions & 4 deletions .github/workflows/dependabot-automerge.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
name: Dependabot auto-merge
on: pull_request_target

permissions:
pull-requests: write
contents: write
jobs:
dependabot:
uses: magemonkeystudio/.github/.github/workflows/reusable-dependabot-automerge.yml@main
secrets: inherit

runs-on: ubuntu-latest
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: dependabot-metadata
uses: dependabot/fetch-metadata@v1
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.ACTIONS_PAT}}
54 changes: 50 additions & 4 deletions .github/workflows/devbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,53 @@ on:

jobs:
deploy:
uses: magemonkeystudio/.github/.github/workflows/reusable-build.yml@main
secrets: inherit
with:
is_dev: true
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
name: Checkout repo
with:
token: ${{ secrets.ACTIONS_PAT }}
- name: Configure git
run: |
git config user.name "Build Monkey"
git config user.email "<>"
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: 'Create settings.xml'
uses: s4u/maven-settings-action@v3.0.0
with:
githubServer: false
servers: '[{"id": "magemonkey-repo", "username": "${{ secrets.REPO_USERNAME }}", "password": "${{ secrets.DEPLOY_KEY }}"}]'
- name: Publish to Travja Repo
env:
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
mvn clean deploy -P gpg,publish -DcreateChecksum=true 2>&1 | tee log.txt
result_code=${PIPESTATUS[0]}
exit $result_code
- name: Tag release version
run: |
version=$(mvn org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout)
git tag -a $version -m "Dev $version"
- name: Update version
run: python ./.github/update_version.py true
- name: Push to git
run: |
git add .
git reset settings.xml log.txt toolchains.xml
git commit -m "[ci skip] Update dev version"
git push
git push --tags
- name: Notify Discord
run: |
python -m venv .venv
.venv/bin/pip install simplejson requests
.venv/bin/python ./.github/notify_published.py ${{ secrets.WEBHOOK_URL }} true
21 changes: 19 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@ on:

jobs:
build:
uses: magemonkeystudio/.github/.github/workflows/reusable-maven.yml@main
secrets: inherit

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: 'Create settings.xml'
uses: s4u/maven-settings-action@v3.0.0
with:
githubServer: false
- name: Build with Maven
run: mvn clean package -e
64 changes: 60 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,63 @@ on:

jobs:
deploy:
uses: magemonkeystudio/.github/.github/workflows/reusable-build.yml@main
secrets: inherit
with:
is_dev: false
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.ACTIONS_PAT }}
- name: Configure git
run: |
git config user.name "Build Monkey"
git config user.email "<>"
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: 'Create settings.xml'
uses: s4u/maven-settings-action@v3.0.0
with:
githubServer: false
servers: '[{"id": "magemonkey-repo", "username": "${{ secrets.REPO_USERNAME }}", "password": "${{ secrets.DEPLOY_KEY }}"}]'
- name: Update version
run: python ./.github/update_version.py false true
- name: Publish to Travja Repo
env:
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
mvn clean deploy -P gpg,publish -DcreateChecksum=true 2>&1 | tee log.txt
result_code=${PIPESTATUS[0]}
exit $result_code
- name: Update README
run: python ./.github/update_readme.py
- name: Tag release version
run: |
git add .
git commit -m "[ci skip] Update release version"
version=$(mvn org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout)
git tag -a $version -m "Release $version"
git push
git push --tags
git fetch --unshallow --all
git checkout dev
git merge -X theirs --no-edit main
- name: Update version
run: python ./.github/update_version.py
- name: Update version
run: python ./.github/update_version.py true
- name: Push to git
run: |
git add .
git commit -m "[ci skip] Update version for development"
git push
- name: Notify Discord
run: |
python -m venv .venv
.venv/bin/pip install simplejson requests
.venv/bin/python ./.github/notify_published.py ${{ secrets.WEBHOOK_URL }}
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[![Build](https://github.com/magemonkeystudio/divinity/actions/workflows/release.yml/badge.svg?branch=main)](https://repo.travja.dev/releases/studio/magemonkey/divinity/1.0.2-R0.65-SNAPSHOT)
[![Build](https://github.com/magemonkeystudio/divinity/actions/workflows/devbuild.yml/badge.svg?branch=dev)](https://repo.travja.dev/snapshots/studio/magemonkey/divinity/1.0.2-R0.65-SNAPSHOT)
[![Discord](https://dcbadge.limes.pink/api/server/mQrkW4htUA?style=flat)](https://discord.gg/mQrkW4htUA)
[![Build](https://github.com/magemonkeystudio/divinity/actions/workflows/release.yml/badge.svg?branch=main)](https://repo.travja.dev/releases/studio/magemonkey/divinity/1.0.2-R0.56-SNAPSHOT)
[![Build](https://github.com/magemonkeystudio/divinity/actions/workflows/devbuild.yml/badge.svg?branch=dev)](https://repo.travja.dev/snapshots/studio/magemonkey/divinity/1.0.2-R0.56-SNAPSHOT)
[![Discord](https://dcbadge.limes.pink/api/server/6UzkTe6RvW?style=flat)](https://discord.gg/6UzkTe6RvW)

# Divinity

If you wish to use Divinity as a dependency in your projects, Divinity is available through our repository.

If you wish to use Divinity as a dependency in your projects, Divinity is available through Maven Central
or snapshots through Sonatype.

```xml
<repository>
Expand All @@ -16,7 +16,7 @@ If you wish to use Divinity as a dependency in your projects, Divinity is availa
<dependency>
<groupId>studio.magemonkey</groupId>
<artifactId>divinity</artifactId>
<version>1.0.2-R0.65-SNAPSHOT</version>
<version>1.0.2-R0.56-SNAPSHOT</version>
</dependency>
```

Expand Down
6 changes: 3 additions & 3 deletions doc/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[![Build](https://github.com/magemonkeystudio/${project.artifactId}/actions/workflows/release.yml/badge.svg?branch=main)](https://repo.travja.dev/releases/studio/magemonkey/${project.artifactId}/${project.version})
[![Build](https://github.com/magemonkeystudio/${project.artifactId}/actions/workflows/devbuild.yml/badge.svg?branch=dev)](https://repo.travja.dev/snapshots/studio/magemonkey/${project.artifactId}/${project.version})
[![Discord](https://dcbadge.limes.pink/api/server/mQrkW4htUA?style=flat)](https://discord.gg/mQrkW4htUA)
[![Discord](https://dcbadge.limes.pink/api/server/6UzkTe6RvW?style=flat)](https://discord.gg/6UzkTe6RvW)

# ${project.name}

If you wish to use ${project.name} as a dependency in your projects, ${project.name} is available through our repository.

If you wish to use ${project.name} as a dependency in your projects, ${project.name} is available through Maven Central
or snapshots through Sonatype.

```xml
<repository>
Expand Down
Loading
Loading