Skip to content

Commit 9bef9f5

Browse files
committed
Initial deployment
1 parent 24e3a21 commit 9bef9f5

48 files changed

Lines changed: 11375 additions & 3 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
root = true
2+
3+
[*]
4+
indent_size = 2
5+
max_line_length = 100
6+
indent_style = space
7+
insert_final_newline = true
8+
trim_trailing_whitespace = true
9+
ij_kotlin_allow_trailing_comma = true
10+
ij_kotlin_allow_trailing_comma_on_call_site = true
11+
12+
[*.{kt, kts}]
13+
ktlint_standard_filename = disabled
14+
ktlint_standard_max-line-length = disabled

.github/CODEOWNERS

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Lines starting with '#' are comments.
2+
# Each line is a file pattern followed by one or more owners.
3+
4+
# More details are here: https://help.github.com/articles/about-codeowners/
5+
6+
# The '*' pattern is global owners.
7+
# Not adding in this PR, but I'd like to try adding a global owner set with the entire team.
8+
# One interpretation of their docs is that global owners are added only if not removed
9+
# by a more local rule.
10+
11+
# Order is important. The last matching pattern has the most precedence.
12+
# The folders are ordered as follows:
13+
14+
# In each subsection folders are ordered first by depth, then alphabetically.
15+
# This should make it easy to add new rules without breaking existing ones.
16+
* @teogor

.github/FUNDING.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# These are supported funding model platforms
2+
3+
github: [ teogor ]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

.github/workflows/publish-docs.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Publish API Docs
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
9+
permissions:
10+
contents: write
11+
pages: write
12+
id-token: write
13+
pull-requests: write
14+
15+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
16+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
17+
concurrency:
18+
group: "api-docs"
19+
cancel-in-progress: false
20+
21+
env:
22+
DESTINATION_BRANCH: docs/${{ github.event.repository.owner.name }}/${{ github.event.repository.name }}/${{ github.sha }}
23+
REPOSITORY: ${{ github.event.repository.name }}
24+
REPO: ${{ github.event.repository.owner.name }}/${{ github.event.repository.name }}
25+
DISPLAY_NAME: Xenoglot
26+
27+
jobs:
28+
synchronize-documentation:
29+
runs-on: ubuntu-latest
30+
name: Synchronize Repository API Documentation
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
# Grants execute permission to gradle (safety step)
35+
- name: Grant Permissions to gradlew
36+
run: chmod +x gradlew
37+
38+
- name: Setup Java
39+
uses: actions/setup-java@v3
40+
with:
41+
distribution: temurin
42+
java-version: 17
43+
44+
- name: Generate API Documentation
45+
run: ./gradlew dokkaHtmlMultiModule
46+
47+
- name: Relocate API Documentation Assets
48+
run: |
49+
mkdir -p docs/${{ env.REPOSITORY }}/documentation
50+
cp -r build/dokka/htmlMultiModule/* docs/${{ env.REPOSITORY }}/documentation
51+
52+
- id: publish-docs
53+
name: Deploy API Documentation
54+
uses: ./.github/workflows/sync-docs/
55+
env:
56+
API_TOKEN_GITHUB: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
57+
with:
58+
source-file: docs/${{ env.REPOSITORY }}/documentation/
59+
destination-folder: ${{ env.REPOSITORY }}
60+
destination-repo: teogor/source.teogor.dev
61+
user-email: open-source@teogor.dev
62+
user-name: Teodor Grigor
63+
destination-branch-create: ${{ env.DESTINATION_BRANCH }}
64+
65+
build-and-deploy:
66+
needs: synchronize-documentation
67+
name: Build and Deploy Updated API Documentation
68+
runs-on: ubuntu-latest
69+
steps:
70+
- name: Checkout other repository
71+
uses: actions/checkout@v3
72+
with:
73+
repository: teogor/source.teogor.dev
74+
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
75+
76+
- name: Create PR (Pull Request)
77+
run: |
78+
json=$(curl -L \
79+
-X POST \
80+
-H "Accept: application/vnd.github+json" \
81+
-H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \
82+
-H "X-GitHub-Api-Version: 2022-11-28" \
83+
https://api.github.com/repos/teogor/source.teogor.dev/pulls \
84+
-d '{
85+
"title":"Updated documentation for `${{ env.REPO }}`",
86+
"body":"## 🚀 **Updated Documentation for ${{ env.DISPLAY_NAME }}** 🚀\n\nThis pull request brings you the latest updates to the [${{ env.DISPLAY_NAME }}](https://github.com/${{ env.REPO }}) documentation, ensuring you have access to the most comprehensive and informative guide for using this powerful library.\n\n-------\n\n* Generated by [Publish Docs](https://github.com/${{ env.REPO }}/actions/workflows/publish-docs.yml)\n\n* From [${{ env.REPO }}](https://github.com/${{ env.REPO }})",
87+
"head":"${{ env.DESTINATION_BRANCH }}",
88+
"base":"main"
89+
}' | jq .)
90+
91+
number=$(jq '.number' <<< ${json})
92+
93+
curl -L \
94+
-X POST \
95+
-H "Accept: application/vnd.github+json" \
96+
-H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \
97+
-H "X-GitHub-Api-Version: 2022-11-28" \
98+
https://api.github.com/repos/teogor/source.teogor.dev/issues/${number}/labels \
99+
-d '{"labels":["@documentation"]}'
100+
101+
curl -L \
102+
-X PUT \
103+
-H "Accept: application/vnd.github+json" \
104+
-H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \
105+
-H "X-GitHub-Api-Version: 2022-11-28" \
106+
https://api.github.com/repos/teogor/source.teogor.dev/pulls/${number}/merge \
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Publish to Maven
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
publish:
8+
name: Snapshot build and publish
9+
runs-on: ubuntu-latest
10+
environment: PRODUCTION
11+
timeout-minutes: 120
12+
env:
13+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
14+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
15+
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
16+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
17+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
18+
SONATYPE_CONNECT_TIMEOUT_SECONDS: 120
19+
SONATYPE_CLOSE_TIMEOUT_SECONDS: 1800
20+
21+
steps:
22+
- name: Check out code
23+
uses: actions/checkout@v3.1.0
24+
25+
- name: Set up JDK 17
26+
uses: actions/setup-java@v3.5.1
27+
with:
28+
distribution: 'zulu'
29+
java-version: 17
30+
31+
- name: Grant Permission to Execute Gradle
32+
run: chmod +x gradlew
33+
34+
- name: Publish to MavenCentral
35+
run: |
36+
./gradlew :publish --no-configuration-cache
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: 'Publish Docs'
2+
description: 'Comprehensive publish docs'
3+
branding:
4+
icon: 'git-commit'
5+
color: 'red'
6+
inputs:
7+
source-file:
8+
description: 'Source file from the origin directory'
9+
required: true
10+
destination-repo:
11+
description: 'Destination repository'
12+
required: true
13+
destination-folder:
14+
description: 'Directory to push the file to'
15+
required: false
16+
user-email:
17+
description: 'Email for the git commit'
18+
required: true
19+
user-name:
20+
description: 'GitHub username for the commit'
21+
required: true
22+
destination-branch:
23+
description: 'branch to push file to, defaults to main'
24+
required: false
25+
destination-branch-create:
26+
description: 'Destination branch to create for this commit'
27+
required: false
28+
commit-message:
29+
description: 'A custom message for the commit'
30+
required: false
31+
rename:
32+
description: 'Rename the destination file'
33+
required: false
34+
use-rsync:
35+
description: 'Copy files/directories using rsync instead of cp. Experimental feature, please know your use case'
36+
required: false
37+
git-server:
38+
description: 'Git server host, default github.com'
39+
required: false
40+
default: github.com
41+
runs:
42+
using: "composite"
43+
steps:
44+
- name: Make all .sh files executable
45+
run: find . -type f -name "*.sh" -exec chmod +x {} \;
46+
shell: bash
47+
48+
- run: echo "${{ github.action_path }}" >> $GITHUB_PATH
49+
shell: bash
50+
51+
- name: Execute Entrypoint Script
52+
shell: bash
53+
env:
54+
SOURCE_FILE: ${{ inputs.source-file }}
55+
DESTINATION_REPO: ${{ inputs.destination-repo }}
56+
DESTINATION_FOLDER: ${{ inputs.destination-folder }}
57+
USER_EMAIL: ${{ inputs.user-email }}
58+
USER_NAME: ${{ inputs.user-name }}
59+
DESTINATION_BRANCH: ${{ inputs.destination-branch }}
60+
DESTINATION_BRANCH_CREATE: ${{ inputs.destination-branch-create }}
61+
COMMIT_MESSAGE: ${{ inputs.commit-message }}
62+
GIT_SERVER: ${{ inputs.git-server }}
63+
RENAME: ${{ inputs.rename }}
64+
USE_RSYNC: ${{ inputs.use-rsync }}
65+
run: sync-files.sh
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/bin/sh
2+
3+
set -e
4+
set -x
5+
6+
# Validate required input
7+
if [ -z "$SOURCE_FILE" ]; then
8+
echo "Error: Source file must be specified."
9+
exit 1
10+
fi
11+
12+
# Set default values for optional variables
13+
if [ -z "$GIT_SERVER" ]; then
14+
GIT_SERVER="github.com"
15+
fi
16+
17+
if [ -z "$DESTINATION_BRANCH" ]; then
18+
DESTINATION_BRANCH="main"
19+
fi
20+
21+
# Clone the destination Git repository
22+
OUTPUT_BRANCH="$DESTINATION_BRANCH"
23+
24+
CLONE_DIR=$(mktemp -d)
25+
echo "Cloning destination Git repository: $DESTINATION_REPO"
26+
27+
git config --global user.email "$USER_EMAIL"
28+
git config --global user.name "$USER_NAME"
29+
30+
git clone --single-branch --branch $DESTINATION_BRANCH "https://x-access-token:$API_TOKEN_GITHUB@$GIT_SERVER/$DESTINATION_REPO.git" "$CLONE_DIR"
31+
32+
# Determine the destination file path
33+
DEST_COPY="$CLONE_DIR/$DESTINATION_FOLDER"
34+
35+
if [ ! -z "$RENAME" ]; then
36+
echo "Renaming file to: ${RENAME}"
37+
DEST_COPY="$CLONE_DIR/$DESTINATION_FOLDER/$RENAME"
38+
fi
39+
40+
# Delete the previous folder if it exists
41+
if [ -d "$DEST_COPY" ]; then
42+
echo "Deleting existing folder: $DEST_COPY"
43+
rm -rf "$DEST_COPY"
44+
fi
45+
46+
# Copy the source file to the destination repository
47+
echo "Copying contents to Git repo: $SOURCE_FILE"
48+
49+
mkdir -p $CLONE_DIR/$DESTINATION_FOLDER
50+
51+
if [ -z "$USE_RSYNC" ]; then
52+
echo "Copying using cp"
53+
cp -R "$SOURCE_FILE" "$DEST_COPY"
54+
else
55+
echo "Copying using rsync"
56+
rsync -avrh "$SOURCE_FILE" "$DEST_COPY"
57+
fi
58+
59+
# Check out the specified branch or create a new one
60+
cd "$CLONE_DIR"
61+
62+
if [ ! -z "$DESTINATION_BRANCH_CREATE" ]; then
63+
echo "Creating new branch: $DESTINATION_BRANCH_CREATE"
64+
git checkout -b "$DESTINATION_BRANCH_CREATE"
65+
OUTPUT_BRANCH="$DESTINATION_BRANCH_CREATE"
66+
fi
67+
68+
if [ -z "$COMMIT_MESSAGE" ]; then
69+
COMMIT_MESSAGE="Automated updates based on https://$GIT_SERVER/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA}"
70+
fi
71+
72+
# Add the copied file to the staging area
73+
echo "Adding git commit"
74+
git add .
75+
76+
# Commit changes if there are any
77+
if git status | grep -q "Changes to be committed"; then
78+
echo "Committing changes with message: $COMMIT_MESSAGE"
79+
git commit --message "$COMMIT_MESSAGE"
80+
81+
echo "Pushing git commit to branch: $OUTPUT_BRANCH"
82+
git push -u origin HEAD:"$OUTPUT_BRANCH"
83+
else
84+
echo "No changes detected, skipping commit and push"
85+
fi

0 commit comments

Comments
 (0)