gitea port
This commit is contained in:
+12
-13
@@ -7,24 +7,24 @@ Spoilers are expanded (open by default) if:
|
|||||||
1. Total patch count <= AUTO_EXPAND_THRESHOLD.
|
1. Total patch count <= AUTO_EXPAND_THRESHOLD.
|
||||||
2. The README marker explicitly says: <!-- PATCHES_START EXPANDED -->
|
2. The README marker explicitly says: <!-- PATCHES_START EXPANDED -->
|
||||||
|
|
||||||
python3 generate_patches_readme.py <owner/repo> <branch> [patches-list.json] [README.md]
|
python3 generate_patches_readme.py <server-url> <owner/repo> <branch> [patches-list.json] [README.md]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import os
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
if len(sys.argv) < 3:
|
if len(sys.argv) < 4:
|
||||||
print("Usage: generate_patches_readme.py <owner/repo> <branch> [json] [readme]")
|
print("Usage: generate_patches_readme.py <server-url> <owner/repo> <branch> [json] [readme]")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
repo_full = sys.argv[1]
|
server_url = sys.argv[1].rstrip("/")
|
||||||
branch = sys.argv[2]
|
repo_full = sys.argv[2]
|
||||||
json_path = Path(sys.argv[3]) if len(sys.argv) > 3 else Path("patches-list.json")
|
branch = sys.argv[3]
|
||||||
readme_path = Path(sys.argv[4]) if len(sys.argv) > 4 else Path("README.md")
|
json_path = Path(sys.argv[4]) if len(sys.argv) > 4 else Path("patches-list.json")
|
||||||
|
readme_path = Path(sys.argv[5]) if len(sys.argv) > 5 else Path("README.md")
|
||||||
|
|
||||||
|
|
||||||
if "/" not in repo_full:
|
if "/" not in repo_full:
|
||||||
@@ -70,7 +70,7 @@ for patch in data["patches"]:
|
|||||||
|
|
||||||
|
|
||||||
def anchor(name):
|
def anchor(name):
|
||||||
"""Convert a patch name to a GitHub-compatible anchor slug."""
|
"""Convert a patch name to a Markdown anchor slug."""
|
||||||
return re.sub(r"-+", "-", re.sub(r"[^a-z0-9]+", "-", name.lower())).strip("-")
|
return re.sub(r"-+", "-", re.sub(r"[^a-z0-9]+", "-", name.lower())).strip("-")
|
||||||
|
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ def spoiler(label, count, targets, tbl, expanded=False):
|
|||||||
def build_content(expanded=False):
|
def build_content(expanded=False):
|
||||||
"""Build the full generated patches section."""
|
"""Build the full generated patches section."""
|
||||||
lines = [
|
lines = [
|
||||||
f"> **[v{ver}](https://github.com/{owner}/{repo}/releases/tag/v{ver})**"
|
f"> **[v{ver}]({server_url}/{owner}/{repo}/releases/tag/v{ver})**"
|
||||||
f" • `{branch}` • "
|
f" • `{branch}` • "
|
||||||
f"{total} patches total"
|
f"{total} patches total"
|
||||||
]
|
]
|
||||||
@@ -213,9 +213,8 @@ expanded = (
|
|||||||
|
|
||||||
generated = build_content(expanded=expanded)
|
generated = build_content(expanded=expanded)
|
||||||
|
|
||||||
# Replace template links if present
|
# Replace template links if present.
|
||||||
readme = readme.replace("https://morphe.software/add-source?github=xyz-user/xyz-patches", f"https://morphe.software/add-source?github={repo_full}")
|
readme = readme.replace("https://github.com/xyz-user/xyz-patches", f"{server_url}/{repo_full}")
|
||||||
readme = readme.replace("https://github.com/xyz-user/xyz-patches", f"https://github.com/{repo_full}")
|
|
||||||
|
|
||||||
new_readme = re.sub(
|
new_readme = re.sub(
|
||||||
rf"{START_PATTERN}.*?{re.escape(END_MARKER)}",
|
rf"{START_PATTERN}.*?{re.escape(END_MARKER)}",
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
const { appendFile, readFile, readdir, writeFile } = require('node:fs/promises');
|
||||||
|
const path = require('node:path');
|
||||||
|
|
||||||
|
function releaseEnvironment(context) {
|
||||||
|
const env = context.env ?? process.env;
|
||||||
|
const serverUrl = env.GITEA_URL?.replace(/\/$/, '');
|
||||||
|
const repository = env.GITEA_REPOSITORY;
|
||||||
|
const token = env.GITEA_TOKEN;
|
||||||
|
|
||||||
|
if (!serverUrl || !repository || !token) {
|
||||||
|
throw new Error('GITEA_URL, GITEA_REPOSITORY, and GITEA_TOKEN are required');
|
||||||
|
}
|
||||||
|
if (!/^https?:\/\//.test(serverUrl)) {
|
||||||
|
throw new Error('GITEA_URL must be an HTTP(S) URL');
|
||||||
|
}
|
||||||
|
if (!/^[^/]+\/[^/]+$/.test(repository)) {
|
||||||
|
throw new Error('GITEA_REPOSITORY must use the owner/repository format');
|
||||||
|
}
|
||||||
|
|
||||||
|
return { serverUrl, repository, token };
|
||||||
|
}
|
||||||
|
|
||||||
|
async function giteaRequest(url, token, options = {}) {
|
||||||
|
const response = await fetch(url, {
|
||||||
|
...options,
|
||||||
|
headers: {
|
||||||
|
Authorization: `token ${token}`,
|
||||||
|
...options.headers,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
const body = (await response.text()).slice(0, 2_000);
|
||||||
|
throw new Error(`Gitea API request failed (${response.status} ${response.statusText}): ${body}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.verifyConditions = async (_pluginConfig, context) => {
|
||||||
|
releaseEnvironment(context);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.prepare = async (pluginConfig, context) => {
|
||||||
|
const { nextRelease, cwd } = context;
|
||||||
|
const notes = nextRelease.notes?.trim();
|
||||||
|
if (!notes) return;
|
||||||
|
|
||||||
|
const { serverUrl, repository } = releaseEnvironment(context);
|
||||||
|
const changelogPath = path.resolve(cwd, pluginConfig.changelogFile ?? 'CHANGELOG.md');
|
||||||
|
const releaseJsonPath = path.resolve(cwd, pluginConfig.releaseJsonPath ?? 'patches-bundle.json');
|
||||||
|
|
||||||
|
let currentChangelog = '';
|
||||||
|
try {
|
||||||
|
currentChangelog = (await readFile(changelogPath, 'utf8')).trim();
|
||||||
|
} catch (error) {
|
||||||
|
if (error.code !== 'ENOENT') throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
await writeFile(
|
||||||
|
changelogPath,
|
||||||
|
`${notes}\n${currentChangelog ? `\n${currentChangelog}\n` : ''}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
const version = nextRelease.version;
|
||||||
|
const assetName = `patches-${version}.mpp`;
|
||||||
|
const releaseData = {
|
||||||
|
created_at: new Date().toISOString().replace(/\.\d{3}Z$/, ''),
|
||||||
|
description: notes,
|
||||||
|
download_url: `${serverUrl}/${repository}/releases/download/${nextRelease.gitTag}/${assetName}`,
|
||||||
|
signature_download_url: '',
|
||||||
|
version,
|
||||||
|
};
|
||||||
|
await writeFile(releaseJsonPath, `${JSON.stringify(releaseData, null, 2)}\n`);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.publish = async (pluginConfig, context) => {
|
||||||
|
const { serverUrl, repository, token } = releaseEnvironment(context);
|
||||||
|
const { branch, cwd, nextRelease } = context;
|
||||||
|
const repositoryPath = repository.split('/').map(encodeURIComponent).join('/');
|
||||||
|
const apiUrl = `${serverUrl}/api/v1/repos/${repositoryPath}`;
|
||||||
|
|
||||||
|
const assetDirectory = path.resolve(
|
||||||
|
cwd,
|
||||||
|
pluginConfig.assetDirectory ?? 'patches/build/libs',
|
||||||
|
);
|
||||||
|
const assetNames = (await readdir(assetDirectory))
|
||||||
|
.filter((name) => /\.mpp(?:\.asc)?$/.test(name))
|
||||||
|
.filter((name) => !/(?:sources|javadoc)/.test(name))
|
||||||
|
.sort();
|
||||||
|
|
||||||
|
if (assetNames.length === 0) {
|
||||||
|
throw new Error(`No release assets found in ${assetDirectory}`);
|
||||||
|
}
|
||||||
|
const releaseResponse = await giteaRequest(`${apiUrl}/releases`, token, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({
|
||||||
|
body: nextRelease.notes,
|
||||||
|
draft: false,
|
||||||
|
name: nextRelease.name,
|
||||||
|
prerelease: Boolean(branch.prerelease),
|
||||||
|
tag_name: nextRelease.gitTag,
|
||||||
|
target_commitish: branch.name,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
const release = await releaseResponse.json();
|
||||||
|
|
||||||
|
for (const assetName of assetNames) {
|
||||||
|
const contents = await readFile(path.join(assetDirectory, assetName));
|
||||||
|
const form = new FormData();
|
||||||
|
form.append('attachment', new Blob([contents]), assetName);
|
||||||
|
await giteaRequest(
|
||||||
|
`${apiUrl}/releases/${release.id}/assets?name=${encodeURIComponent(assetName)}`,
|
||||||
|
token,
|
||||||
|
{ method: 'POST', body: form },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.env.GITHUB_OUTPUT) {
|
||||||
|
await appendFile(
|
||||||
|
process.env.GITHUB_OUTPUT,
|
||||||
|
`new_release_published=true\nnew_release_git_tag=${nextRelease.gitTag}\n`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return { name: release.name, url: release.html_url };
|
||||||
|
};
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
name: Open a PR to main
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- dev
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
pull-request:
|
||||||
|
name: Open pull request
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Open pull request
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
GITEA_URL: ${{ gitea.server_url }}
|
||||||
|
GITEA_REPOSITORY: ${{ gitea.repository }}
|
||||||
|
SOURCE_BRANCH: ${{ gitea.ref_name }}
|
||||||
|
TARGET_BRANCH: main
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
api_url="${GITEA_URL%/}/api/v1"
|
||||||
|
auth_header="Authorization: token ${GITEA_TOKEN}"
|
||||||
|
|
||||||
|
open_pulls="$(
|
||||||
|
curl --fail-with-body --silent --show-error \
|
||||||
|
--get \
|
||||||
|
--header "$auth_header" \
|
||||||
|
--data-urlencode "state=open" \
|
||||||
|
--data-urlencode "base_branch=${TARGET_BRANCH}" \
|
||||||
|
--data-urlencode "limit=50" \
|
||||||
|
"${api_url}/repos/${GITEA_REPOSITORY}/pulls"
|
||||||
|
)"
|
||||||
|
if jq -e --arg branch "$SOURCE_BRANCH" \
|
||||||
|
'any(.[]; .head.ref == $branch)' <<<"$open_pulls" >/dev/null; then
|
||||||
|
echo "Pull request already exists."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
commits="$(git rev-list --count "origin/${TARGET_BRANCH}..HEAD")"
|
||||||
|
if [[ "$commits" -eq 0 ]]; then
|
||||||
|
echo "No commits between ${TARGET_BRANCH} and ${SOURCE_BRANCH}. Skipping pull request creation."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
payload="$(
|
||||||
|
jq -n \
|
||||||
|
--arg base "$TARGET_BRANCH" \
|
||||||
|
--arg head "$SOURCE_BRANCH" \
|
||||||
|
--arg title 'chore: Merge branch `dev` to `main`' \
|
||||||
|
--arg body 'When dev (pre-release) is ready, merge this pull request to create a new stable release.' \
|
||||||
|
'{base: $base, head: $head, title: $title, body: $body}'
|
||||||
|
)"
|
||||||
|
|
||||||
|
curl --fail-with-body --silent --show-error \
|
||||||
|
--request POST \
|
||||||
|
--header "$auth_header" \
|
||||||
|
--header "Content-Type: application/json" \
|
||||||
|
--data "$payload" \
|
||||||
|
"${api_url}/repos/${GITEA_REPOSITORY}/pulls" >/dev/null
|
||||||
|
echo "Pull request created."
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
name: Release
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup Java
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: temurin
|
||||||
|
java-version: '21'
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 'lts/*'
|
||||||
|
cache: npm
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
id: release
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
GITEA_URL: ${{ gitea.server_url }}
|
||||||
|
GITEA_REPOSITORY: ${{ gitea.repository }}
|
||||||
|
GITEA_REF_NAME: ${{ gitea.ref_name }}
|
||||||
|
MORPHE_REGISTRY_USERNAME: ${{ secrets.MORPHE_REGISTRY_USERNAME }}
|
||||||
|
MORPHE_REGISTRY_TOKEN: ${{ secrets.MORPHE_REGISTRY_TOKEN }}
|
||||||
|
run: npx semantic-release
|
||||||
|
|
||||||
|
# Semantic Release performs the Gradle build while publishing. Build only
|
||||||
|
# when no release was produced so every push still verifies compilation.
|
||||||
|
- name: Verify project compiles
|
||||||
|
if: steps.release.outputs.new_release_published != 'true'
|
||||||
|
env:
|
||||||
|
MORPHE_REGISTRY_USERNAME: ${{ secrets.MORPHE_REGISTRY_USERNAME }}
|
||||||
|
MORPHE_REGISTRY_TOKEN: ${{ secrets.MORPHE_REGISTRY_TOKEN }}
|
||||||
|
run: ./gradlew :patches:buildAndroid clean --no-daemon
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
name: 🐞 Bug report
|
|
||||||
description: Report a bug or an issue.
|
|
||||||
title: "bug: "
|
|
||||||
labels: ["Bug report"]
|
|
||||||
body:
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
# Patches template bug report
|
|
||||||
|
|
||||||
Before creating a new bug report, please keep the following in mind:
|
|
||||||
|
|
||||||
- **Do not submit a duplicate bug report**: Search for existing bug reports [here](https://github.com/TEMPLATE/template-patches-template/issues?q=label%3A%22Bug+report%22).
|
|
||||||
- **Review the contribution guidelines**: Make sure your bug report adheres to it. You can find the guidelines [here](https://github.com/TEMPLATE/template-patches-template/blob/main/CONTRIBUTING.md).
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Bug description
|
|
||||||
description: |
|
|
||||||
- Describe your bug in detail
|
|
||||||
- Add steps to reproduce the bug if possible (Step 1. ... Step 2. ...)
|
|
||||||
- Add images and videos if possible
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Error logs
|
|
||||||
description: Exceptions can be captured by running `logcat | grep AndroidRuntime` in a shell.
|
|
||||||
render: shell
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Solution
|
|
||||||
description: If applicable, add a possible solution to the bug.
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Additional context
|
|
||||||
description: Add additional context here.
|
|
||||||
- type: checkboxes
|
|
||||||
id: acknowledgements
|
|
||||||
attributes:
|
|
||||||
label: Acknowledgements
|
|
||||||
description: Your bug report will be closed if you don't follow the checklist below.
|
|
||||||
options:
|
|
||||||
- label: I have checked all open and closed bug reports and this is not a duplicate.
|
|
||||||
required: true
|
|
||||||
- label: I have chosen an appropriate title.
|
|
||||||
required: true
|
|
||||||
- label: All requested information has been provided properly.
|
|
||||||
required: true
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
blank_issues_enabled: false
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
name: ⭐ Feature request
|
|
||||||
description: Create a detailed request for a new feature.
|
|
||||||
title: "feat: "
|
|
||||||
labels: ["Feature request"]
|
|
||||||
body:
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
# Template Patches template feature request
|
|
||||||
|
|
||||||
Before creating a new feature request, please keep the following in mind:
|
|
||||||
|
|
||||||
- **Do not submit a duplicate feature request**: Search for existing feature requests [here](https://github.com/TEMPlATE/TEMPLATE-patches-template/issues?q=label%3A%22Feature+request%22).
|
|
||||||
- **Review the contribution guidelines**: Make sure your feature request adheres to it. You can find the guidelines [here](https://github.com/TEMPLATE/TEMPLATE-patches-template/blob/main/CONTRIBUTING.md).
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Feature description
|
|
||||||
description: |
|
|
||||||
- Describe your feature in detail
|
|
||||||
- Add images, videos, links, examples, references, etc. if possible
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Motivation
|
|
||||||
description: |
|
|
||||||
A strong motivation is necessary for a feature request to be considered.
|
|
||||||
|
|
||||||
- Why should this feature be implemented?
|
|
||||||
- What is the explicit use case?
|
|
||||||
- What are the benefits?
|
|
||||||
- What makes this feature important?
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: checkboxes
|
|
||||||
id: acknowledgements
|
|
||||||
attributes:
|
|
||||||
label: Acknowledgements
|
|
||||||
description: Your feature request will be closed if you don't follow the checklist below.
|
|
||||||
options:
|
|
||||||
- label: I have checked all open and closed feature requests and this is not a duplicate
|
|
||||||
required: true
|
|
||||||
- label: I have chosen an appropriate title.
|
|
||||||
required: true
|
|
||||||
- label: All requested information has been provided properly.
|
|
||||||
required: true
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
version: 2
|
|
||||||
updates:
|
|
||||||
- package-ecosystem: github-actions
|
|
||||||
labels: []
|
|
||||||
directory: /
|
|
||||||
target-branch: dev
|
|
||||||
schedule:
|
|
||||||
interval: monthly
|
|
||||||
|
|
||||||
- package-ecosystem: npm
|
|
||||||
labels: []
|
|
||||||
directory: /
|
|
||||||
target-branch: dev
|
|
||||||
schedule:
|
|
||||||
interval: monthly
|
|
||||||
ignore:
|
|
||||||
# version 10.x and later may not generate release notes correctly
|
|
||||||
# https://github.com/conventional-changelog/conventional-changelog/issues/1495
|
|
||||||
- dependency-name: "conventional-changelog-conventionalcommits"
|
|
||||||
|
|
||||||
- package-ecosystem: gradle
|
|
||||||
labels: []
|
|
||||||
directory: /
|
|
||||||
target-branch: dev
|
|
||||||
schedule:
|
|
||||||
interval: monthly
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
name: Open a PR to main
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- dev
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
pull-requests: write
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
pull-request:
|
|
||||||
name: Open pull request
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v7
|
|
||||||
|
|
||||||
- name: Open pull request
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
SOURCE_BRANCH: ${{ github.ref_name }}
|
|
||||||
TARGET_BRANCH: main
|
|
||||||
run: |
|
|
||||||
# Check if PR already exists (base=main, head=dev)
|
|
||||||
if gh pr list --base "$TARGET_BRANCH" --head "$SOURCE_BRANCH" --json number | jq -e '. | length > 0' >/dev/null; then
|
|
||||||
echo "Pull request already exists."
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if there are any commits between branches
|
|
||||||
COMMITS=$(gh api "repos/${{ github.repository }}/compare/${TARGET_BRANCH}...${SOURCE_BRANCH}" --jq '.total_commits')
|
|
||||||
if [ "$COMMITS" -eq 0 ]; then
|
|
||||||
echo "No commits between $TARGET_BRANCH and $SOURCE_BRANCH. Skipping PR creation."
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Try to create the PR
|
|
||||||
gh pr create \
|
|
||||||
--base "$TARGET_BRANCH" \
|
|
||||||
--head "$SOURCE_BRANCH" \
|
|
||||||
--title 'chore: Merge branch `dev` to `main`' \
|
|
||||||
--body "When dev (pre-release) is ready, then merge this pull request to create a new stable release." \
|
|
||||||
|| {
|
|
||||||
echo "::error::Pull request creation failed. Ensure 'Allow GitHub Actions to create and approve pull requests' is enabled in the repo Settings > Actions > General > Workflow permissions"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
name: Release
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
release:
|
|
||||||
name: Release
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
packages: write
|
|
||||||
id-token: write
|
|
||||||
attestations: write
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v7
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Setup Java
|
|
||||||
uses: actions/setup-java@v5.7.0
|
|
||||||
with:
|
|
||||||
distribution: 'temurin'
|
|
||||||
java-version: '21'
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
uses: actions/setup-node@v7
|
|
||||||
with:
|
|
||||||
node-version: 'lts/*'
|
|
||||||
cache: 'npm'
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: npm install
|
|
||||||
|
|
||||||
# Semantic release runs its own Gradle build command.
|
|
||||||
# Only dev and main branch will generate a release as specified by .releaserc
|
|
||||||
- name: Release
|
|
||||||
uses: cycjimmy/semantic-release-action@v6
|
|
||||||
id: release
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Attest
|
|
||||||
if: steps.release.outputs.new_release_published == 'true'
|
|
||||||
uses: actions/attest-build-provenance@v4
|
|
||||||
with:
|
|
||||||
subject-name: 'Morphe Patches ${{ steps.release.outputs.new_release_git_tag }}'
|
|
||||||
subject-path: patches/build/libs/patches-*.mpp
|
|
||||||
|
|
||||||
# Always verify compilation when semantic-release did not publish a release.
|
|
||||||
# This covers non-main/dev branches, chore commits, docs commits, etc.
|
|
||||||
- name: Verify project compiles
|
|
||||||
if: steps.release.outputs.new_release_published != 'true'
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
run: ./gradlew :patches:buildAndroid clean --no-daemon
|
|
||||||
+16
-23
@@ -8,7 +8,8 @@
|
|||||||
],
|
],
|
||||||
"plugins": [
|
"plugins": [
|
||||||
[
|
[
|
||||||
"@semantic-release/commit-analyzer", {
|
"@semantic-release/commit-analyzer",
|
||||||
|
{
|
||||||
"releaseRules": [
|
"releaseRules": [
|
||||||
{ "type": "fix", "release": "patch" },
|
{ "type": "fix", "release": "patch" },
|
||||||
{ "type": "feat", "release": "minor" },
|
{ "type": "feat", "release": "minor" },
|
||||||
@@ -19,7 +20,8 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"@semantic-release/release-notes-generator", {
|
"@semantic-release/release-notes-generator",
|
||||||
|
{
|
||||||
"preset": "conventionalcommits",
|
"preset": "conventionalcommits",
|
||||||
"presetConfig": {
|
"presetConfig": {
|
||||||
"types": [
|
"types": [
|
||||||
@@ -33,21 +35,18 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"@MorpheApp/changelog", {
|
"./.gitea/scripts/morphe-release.cjs",
|
||||||
"releaseJson": {
|
{
|
||||||
"path": "patches-bundle.json",
|
"changelogFile": "CHANGELOG.md",
|
||||||
"downloadUrlTemplate": "https://github.com/${owner}/${repo}/releases/download/v${version}/patches-${version}.mpp",
|
"releaseJsonPath": "patches-bundle.json",
|
||||||
"signatureUrlTemplate": ""
|
"assetDirectory": "patches/build/libs"
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"gradle-semantic-release-plugin",
|
"gradle-semantic-release-plugin",
|
||||||
[
|
[
|
||||||
"@semantic-release/exec",
|
"@semantic-release/exec",
|
||||||
{
|
{
|
||||||
"prepareCmd": "./gradlew generatePatchesList \
|
"prepareCmd": "./gradlew generatePatchesList && jq '.version=\"${nextRelease.version}\"' patches-list.json > patches-list.json.tmp && mv patches-list.json.tmp patches-list.json && python3 .gitea/scripts/generate_patches_readme.py \"$GITEA_URL\" \"$GITEA_REPOSITORY\" \"$GITEA_REF_NAME\" patches-list.json README.md"
|
||||||
&& jq '.version=\"${nextRelease.version}\"' patches-list.json > patches-list.json.tmp && mv patches-list.json.tmp patches-list.json \
|
|
||||||
&& python3 .github/scripts/generate_patches_readme.py $GITHUB_REPOSITORY $GITHUB_REF_NAME patches-list.json README.md"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@@ -63,21 +62,15 @@
|
|||||||
"message": "chore: Release v${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
|
"message": "chore: Release v${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
[
|
|
||||||
"@semantic-release/github",
|
|
||||||
{
|
|
||||||
"assets": [
|
|
||||||
{
|
|
||||||
"path": "patches/build/libs/patches-!(*sources*|*javadoc*).mpp?(.asc)"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"successComment": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
"@cleyrop-org/semantic-release-backmerge",
|
"@cleyrop-org/semantic-release-backmerge",
|
||||||
{
|
{
|
||||||
"backmergeBranches": [{"from": "main", "to": "dev"}],
|
"backmergeBranches": [
|
||||||
|
{
|
||||||
|
"from": "main",
|
||||||
|
"to": "dev"
|
||||||
|
}
|
||||||
|
],
|
||||||
"clearWorkspace": true
|
"clearWorkspace": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
Generated
-19
@@ -6,7 +6,6 @@
|
|||||||
"": {
|
"": {
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@cleyrop-org/semantic-release-backmerge": "^6.2.0",
|
"@cleyrop-org/semantic-release-backmerge": "^6.2.0",
|
||||||
"@MorpheApp/changelog": "git+https://github.com/MorpheApp/changelog.git#bundle",
|
|
||||||
"@semantic-release/exec": "^7.1.0",
|
"@semantic-release/exec": "^7.1.0",
|
||||||
"@semantic-release/git": "^11.0.1",
|
"@semantic-release/git": "^11.0.1",
|
||||||
"conventional-changelog-conventionalcommits": "^9.3.1",
|
"conventional-changelog-conventionalcommits": "^9.3.1",
|
||||||
@@ -119,24 +118,6 @@
|
|||||||
"node": ">=0.1.90"
|
"node": ">=0.1.90"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@MorpheApp/changelog": {
|
|
||||||
"version": "0.0.1",
|
|
||||||
"resolved": "git+ssh://git@github.com/MorpheApp/changelog.git#caa1e931730f097bb6c4dee636b01c2c24ccd72d",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"@semantic-release/error": "^4.0.0",
|
|
||||||
"aggregate-error": "^5.0.0",
|
|
||||||
"fs-extra": "^11.3.4",
|
|
||||||
"lodash": "^4.18.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=14.17"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"semantic-release": ">=18.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@octokit/auth-token": {
|
"node_modules/@octokit/auth-token": {
|
||||||
"version": "6.0.0",
|
"version": "6.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-6.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-6.0.0.tgz",
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@cleyrop-org/semantic-release-backmerge": "^6.2.0",
|
"@cleyrop-org/semantic-release-backmerge": "^6.2.0",
|
||||||
"@MorpheApp/changelog": "git+https://github.com/MorpheApp/changelog.git#bundle",
|
|
||||||
"@semantic-release/exec": "^7.1.0",
|
"@semantic-release/exec": "^7.1.0",
|
||||||
"@semantic-release/git": "^11.0.1",
|
"@semantic-release/git": "^11.0.1",
|
||||||
"conventional-changelog-conventionalcommits": "^9.3.1",
|
"conventional-changelog-conventionalcommits": "^9.3.1",
|
||||||
|
|||||||
+2
-2
@@ -8,8 +8,8 @@ pluginManagement {
|
|||||||
name = "GitHubPackages"
|
name = "GitHubPackages"
|
||||||
url = uri("https://maven.pkg.github.com/MorpheApp/registry")
|
url = uri("https://maven.pkg.github.com/MorpheApp/registry")
|
||||||
credentials {
|
credentials {
|
||||||
username = providers.gradleProperty("gpr.user").orNull ?: System.getenv("GITHUB_ACTOR")
|
username = providers.gradleProperty("gpr.user").orNull ?: System.getenv("MORPHE_REGISTRY_USERNAME")
|
||||||
password = providers.gradleProperty("gpr.key").orNull ?: System.getenv("GITHUB_TOKEN")
|
password = providers.gradleProperty("gpr.key").orNull ?: System.getenv("MORPHE_REGISTRY_TOKEN")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
maven { url = uri("https://jitpack.io") }
|
maven { url = uri("https://jitpack.io") }
|
||||||
|
|||||||
Reference in New Issue
Block a user