Skip to content

Commit 3a045ed

Browse files
authored
Initial commit
0 parents  commit 3a045ed

9 files changed

Lines changed: 857 additions & 0 deletions

File tree

.gitattributes

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
###############################################################################
2+
# Set default behavior to automatically normalize line endings.
3+
###############################################################################
4+
* text=auto
5+
6+
###############################################################################
7+
# Set default behavior for command prompt diff.
8+
#
9+
# This is need for earlier builds of msysgit that does not have it on by
10+
# default for csharp files.
11+
# Note: This is only used by command line
12+
###############################################################################
13+
#*.cs diff=csharp
14+
15+
###############################################################################
16+
# Set the merge driver for project and solution files
17+
#
18+
# Merging from the command prompt will add diff markers to the files if there
19+
# are conflicts (Merging from VS is not affected by the settings below, in VS
20+
# the diff markers are never inserted). Diff markers may cause the following
21+
# file extensions to fail to load in VS. An alternative would be to treat
22+
# these files as binary and thus will always conflict and require user
23+
# intervention with every merge. To do so, just uncomment the entries below
24+
###############################################################################
25+
#*.sln merge=binary
26+
#*.csproj merge=binary
27+
#*.vbproj merge=binary
28+
#*.vcxproj merge=binary
29+
#*.vcproj merge=binary
30+
#*.dbproj merge=binary
31+
#*.fsproj merge=binary
32+
#*.lsproj merge=binary
33+
#*.wixproj merge=binary
34+
#*.modelproj merge=binary
35+
#*.sqlproj merge=binary
36+
#*.wwaproj merge=binary
37+
38+
###############################################################################
39+
# behavior for image files
40+
#
41+
# image files are treated as binary by default.
42+
###############################################################################
43+
#*.jpg binary
44+
#*.png binary
45+
#*.gif binary
46+
47+
###############################################################################
48+
# diff behavior for common document formats
49+
#
50+
# Convert binary document formats to text before diffing them. This feature
51+
# is only available from the command line. Turn it on by uncommenting the
52+
# entries below.
53+
###############################################################################
54+
#*.doc diff=astextplain
55+
#*.DOC diff=astextplain
56+
#*.docx diff=astextplain
57+
#*.DOCX diff=astextplain
58+
#*.dot diff=astextplain
59+
#*.DOT diff=astextplain
60+
#*.pdf diff=astextplain
61+
#*.PDF diff=astextplain
62+
#*.rtf diff=astextplain
63+
#*.RTF diff=astextplain
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# GitHub Actions workflow to publish DaxLib packages
2+
#
3+
# Version: 1.0.0
4+
#
5+
# HOW TO USE:
6+
# 1. Go to "Actions" in your GitHub repository
7+
# 2. Click on "publish-package" in the workflow list
8+
# 3. Click the "Run workflow" button and confirm
9+
# 4. Wait for the workflow to complete
10+
# 5. Create a Pull Request to the official DaxLib repository (link provided in the summary after completion)
11+
#
12+
# WHAT IT DOES:
13+
# - Reads your package from the current repository
14+
# - Copies it to your daxlib fork
15+
# - Creates (or updates) a branch with your changes
16+
# - Provides you with a link to open a Pull Request to the official DaxLib repository
17+
#
18+
# REQUIREMENTS:
19+
# - A fork of the daxlib repository under your account
20+
# - A Personal Access Token (PAT) saved as DAXLIBFORK_PAT in repository secrets
21+
22+
name: publish-package
23+
24+
on:
25+
workflow_dispatch:
26+
27+
permissions:
28+
contents: read
29+
30+
env:
31+
# Name of the forked daxlib repository (change if your fork has a different name)
32+
DAXLIBFORK_NAME: ${{ github.repository_owner }}/daxlib
33+
34+
jobs:
35+
publish:
36+
runs-on: ubuntu-latest
37+
steps:
38+
# Checkout the current repository
39+
- name: Checkout source
40+
uses: actions/checkout@v4
41+
with:
42+
repository: ${{ github.repository }}
43+
path: source-repo
44+
45+
# Checkout the daxlib fork repository
46+
- name: Checkout upstream
47+
uses: actions/checkout@v4
48+
with:
49+
repository: ${{ env.DAXLIBFORK_NAME }}
50+
path: fork-repo
51+
token: ${{ secrets.DAXLIBFORK_PAT }}
52+
53+
# Configure Git
54+
- name: Git config
55+
working-directory: fork-repo
56+
run: |
57+
git config user.name "${{ github.actor }}"
58+
git config user.email "${{ github.actor }}@users.noreply.github.com"
59+
60+
# Read the package version from the manifest
61+
- name: Read package manifest
62+
id: package
63+
working-directory: source-repo
64+
run: |
65+
PACKAGE_NAME=$(jq -r '.id' src/manifest.daxlib)
66+
echo "name=${PACKAGE_NAME}" >> $GITHUB_OUTPUT
67+
echo "Package name: ${PACKAGE_NAME}"
68+
PACKAGE_VERSION=$(jq -r '.version' src/manifest.daxlib)
69+
echo "version=${PACKAGE_VERSION}" >> $GITHUB_OUTPUT
70+
echo "Package version: ${PACKAGE_VERSION}"
71+
PACKAGE_FOLDER="packages/$(echo "${PACKAGE_NAME}" | cut -c1 | tr '[:upper:]' '[:lower:]')/$(echo "${PACKAGE_NAME}" | tr '[:upper:]' '[:lower:]')/${PACKAGE_VERSION}"
72+
echo "folder=${PACKAGE_FOLDER}" >> $GITHUB_OUTPUT
73+
echo "Package folder: ${PACKAGE_FOLDER}"
74+
75+
# Checkout the branch (or create it if it doesn't exist)
76+
- name: Checkout branch
77+
id: branch
78+
working-directory: fork-repo
79+
run: |
80+
BRANCH_NAME="${{ github.event.repository.name }}/publish-${{ steps.package.outputs.name }}-${{ steps.package.outputs.version }}"
81+
echo "name=${BRANCH_NAME}" >> $GITHUB_OUTPUT
82+
echo "Branch name: ${BRANCH_NAME}"
83+
git fetch origin
84+
if git show-ref --verify --quiet "refs/remotes/origin/${BRANCH_NAME}"; then
85+
echo "action=Update" >> $GITHUB_OUTPUT
86+
git checkout "${BRANCH_NAME}"
87+
else
88+
echo "action=Add" >> $GITHUB_OUTPUT
89+
git checkout -b "${BRANCH_NAME}"
90+
fi
91+
92+
# Create the package folder if it doesn't exist
93+
- name: Create package folder
94+
working-directory: fork-repo
95+
run: mkdir -p "${{ steps.package.outputs.folder }}"
96+
97+
# Copy package files to the new folder
98+
- name: Copy package files
99+
run: cp -rv source-repo/src/* "fork-repo/${{ steps.package.outputs.folder }}/"
100+
101+
# Commit changes. If there are no changes, this will fail and stop the workflow
102+
- name: Git commit changes
103+
working-directory: fork-repo
104+
run: git add -A && git commit -m "${{ steps.branch.outputs.action }} package \`${{ steps.package.outputs.name }}\` version ${{ steps.package.outputs.version }}"
105+
106+
# Push to upstream
107+
- name: Git push branch
108+
working-directory: fork-repo
109+
run: git push origin "${{ steps.branch.outputs.name }}"
110+
111+
# Print summary
112+
- name: Print summary
113+
run: |
114+
if [ "${{ steps.branch.outputs.action }}" == "Add" ]; then
115+
STATUS_ICON="✅"
116+
BADGE_COLOR="blue"
117+
STAT_INSTRUCTIONS="Your package is ready to be published."
118+
NEXT_INSTRUCTIONS="Click the button below to create a Pull Request and submit your package to DAX Lib:"
119+
else
120+
STATUS_ICON="🔄"
121+
BADGE_COLOR="orange"
122+
STAT_INSTRUCTIONS="Your changes have been applied and are ready for review."
123+
NEXT_INSTRUCTIONS="If a Pull Request already exists, it has already been updated automatically. Otherwise, click the button below to create one."
124+
fi
125+
126+
cat >> $GITHUB_STEP_SUMMARY << EOF
127+
## ${STATUS_ICON} Package **\`${{ steps.package.outputs.name }}\`** version **\`${{ steps.package.outputs.version }}\`**
128+
129+
${STAT_INSTRUCTIONS}
130+
131+
## 📝 Next Step
132+
133+
${NEXT_INSTRUCTIONS}
134+
135+
[![Create Pull Request](https://img.shields.io/badge/Create_Pull_Request-${BADGE_COLOR}?style=for-the-badge&logo=github)](https://github.com/${{ env.DAXLIBFORK_NAME }}/pull/new/${{ steps.branch.outputs.name }})
136+
137+
<details>
138+
<summary>📋 Details (click to expand)</summary>
139+
140+
| | |
141+
|---|---|
142+
| Package name | \`${{ steps.package.outputs.name }}\` |
143+
| Package version | \`${{ steps.package.outputs.version }}\` |
144+
| Package folder | \`${{ steps.package.outputs.folder }}\` |
145+
| Source | \`${{ github.repository }}\` @ \`${{ github.ref_name }}\` |
146+
| Fork | \`${{ env.DAXLIBFORK_NAME }}\` @ \`${{ steps.branch.outputs.name }}\` |
147+
| Create Pull Request URL | \`https://github.com/${{ env.DAXLIBFORK_NAME }}/pull/new/${{ steps.branch.outputs.name }}\` |
148+
149+
</details>
150+
EOF

0 commit comments

Comments
 (0)