Skip to content

Commit b892b64

Browse files
committed
Fix tags, annotations, yml workflow
1 parent 9ba933d commit b892b64

4 files changed

Lines changed: 157 additions & 65 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: 64 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
# Publish workflow to add a new version of a package
1+
# GitHub Actions workflow for publishing DaxLib packages
22
#
3-
# This workflow creates a branch in the daxlib/daxlib GitHub repository
4-
# to add a new version of the package. After the workflow completes,
5-
# a pull request should be created manually to merge the changes.
6-
#
7-
# TODO:
8-
# - Automate the PR creation
3+
# This workflow automates the publication of a new package version to the daxlib/daxlib repository.
4+
# Maintainers can trigger it manually via the "Run workflow" button in the Actions tab.
5+
#
6+
# Steps:
7+
# - Extracts the package name and version from the manifest file
8+
# - Creates or updates a release branch in the upstream repository
9+
# - Copies the package files to the appropriate folder structure
10+
# - Commits and pushes the changes
11+
# - Creates a pull request for new releases
912

1013
name: publish-package-pr
1114

@@ -15,66 +18,92 @@ on:
1518
permissions:
1619
contents: read
1720

18-
env:
19-
DAXLIB_NAME: 'DaxLib.Convert'
20-
DAXLIB_PATH: 'packages/d/daxlib.convert'
21-
2221
jobs:
2322
publish:
2423
runs-on: ubuntu-latest
2524
steps:
2625
# Checkout the current repository
27-
- name: checkout source
26+
- name: Checkout source
2827
uses: actions/checkout@v4
2928
with:
3029
repository: ${{ github.repository }}
3130
path: source-repo
3231

3332
# Checkout the upstream repository daxlib/daxlib
34-
- name: checkout upstream
33+
- name: Checkout upstream
3534
uses: actions/checkout@v4
3635
with:
3736
repository: daxlib/daxlib
3837
path: upstream-repo
3938
token: ${{ secrets.DAXLIB_TOKEN }} # Required to push changes
40-
39+
4140
# Configure Git
42-
- name: git config
41+
- name: Git config
4342
working-directory: upstream-repo
4443
run: |
4544
git config user.name "${{ github.actor }}"
4645
git config user.email "${{ github.actor }}@users.noreply.github.com"
4746
48-
# Extract package version from manifest
49-
- name: get package version
50-
id: get_package_version
47+
# Read the package version from the manifest
48+
- name: Read package manifest
49+
id: package
5150
working-directory: source-repo
5251
run: |
53-
VERSION=$(jq -r '.version' src/manifest.daxlib)
54-
echo "version=$VERSION" >> $GITHUB_OUTPUT
55-
echo "Package version: $VERSION"
52+
PACKAGE_NAME=$(jq -r '.id' src/manifest.daxlib)
53+
echo "name=${PACKAGE_NAME}" >> $GITHUB_OUTPUT
54+
echo "Package name: ${PACKAGE_NAME}"
55+
PACKAGE_VERSION=$(jq -r '.version' src/manifest.daxlib)
56+
echo "version=${PACKAGE_VERSION}" >> $GITHUB_OUTPUT
57+
echo "Package version: ${PACKAGE_VERSION}"
58+
PACKAGE_FOLDER="packages/$(echo "${PACKAGE_NAME}" | cut -c1 | tr '[:upper:]' '[:lower:]')/$(echo "${PACKAGE_NAME}" | tr '[:upper:]' '[:lower:]')/${PACKAGE_VERSION}"
59+
echo "folder=${PACKAGE_FOLDER}" >> $GITHUB_OUTPUT
60+
echo "Package folder: ${PACKAGE_FOLDER}"
5661
57-
# Create the feature branch for the new version
58-
- name: create release branch
62+
# Checkout the branch (or create it if it doesn't exist)
63+
- name: Checkout branch
64+
id: branch
5965
working-directory: upstream-repo
60-
run: git checkout -b "${{ github.event.repository.name }}/release-${{ env.DAXLIB_NAME }}-${{ steps.get_package_version.outputs.version }}"
66+
run: |
67+
BRANCH_NAME="${{ github.event.repository.name }}/publish-${{ steps.package.outputs.name }}-${{ steps.package.outputs.version }}"
68+
echo "name=${BRANCH_NAME}" >> $GITHUB_OUTPUT
69+
echo "Branch name: ${BRANCH_NAME}"
70+
git fetch origin
71+
if git show-ref --verify --quiet "refs/remotes/origin/${BRANCH_NAME}"; then
72+
echo "action=Update" >> $GITHUB_OUTPUT
73+
git checkout "${BRANCH_NAME}"
74+
else
75+
echo "action=Add" >> $GITHUB_OUTPUT
76+
git checkout -b "${BRANCH_NAME}"
77+
fi
6178
62-
# Create the package folder for the new version
63-
- name: create package folder
79+
# Create the package folder if it doesn't exist
80+
- name: Create package folder
6481
working-directory: upstream-repo
65-
run: mkdir -p "${{ env.DAXLIB_PATH }}/${{ steps.get_package_version.outputs.version }}"
82+
run: mkdir -p "${{ steps.package.outputs.folder }}"
6683

6784
# Copy package files to the new folder
68-
- name: copy package files
69-
run: cp -rv source-repo/src/* "upstream-repo/${{ env.DAXLIB_PATH }}/${{ steps.get_package_version.outputs.version }}/"
85+
- name: Copy package files
86+
run: cp -rv source-repo/src/* "upstream-repo/${{ steps.package.outputs.folder }}/"
7087

71-
# Stage and commit changes
72-
- name: git commit changes
88+
# Commit changes
89+
- name: Git commit changes
7390
working-directory: upstream-repo
74-
run: git add -A && git commit -m "Add package ${{ env.DAXLIB_NAME }} version ${{ steps.get_package_version.outputs.version }}"
91+
run: git add -A && git commit -m "${{ steps.branch.outputs.action }} package ${{ steps.package.outputs.name }} version ${{ steps.package.outputs.version }}"
7592

76-
# Push branch to upstream repository
77-
- name: git push upstream
93+
# Push to upstream
94+
- name: Git push upstream
7895
working-directory: upstream-repo
79-
run: git push origin "${{ github.event.repository.name }}/release-${{ env.DAXLIB_NAME }}-${{ steps.get_package_version.outputs.version }}"
96+
run: git push origin "${{ steps.branch.outputs.name }}"
8097

98+
# Create the pull request (if the branch was created)
99+
- name: Create pull request
100+
if: steps.branch.outputs.action == 'Add'
101+
working-directory: upstream-repo
102+
env:
103+
GH_TOKEN: ${{ secrets.DAXLIB_TOKEN }}
104+
run: |
105+
gh pr create \
106+
--title "Add package \`${{ steps.package.outputs.name }}\` version ${{ steps.package.outputs.version }}" \
107+
--body "Automated package publication from ${{ github.repository }}" \
108+
--base main \
109+
--head "${{ steps.branch.outputs.name }}"

0 commit comments

Comments
 (0)