5151 echo "make_draft=false" >> $GITHUB_OUTPUT
5252 fi
5353
54- # Use PAT for checkout so the push triggers no recursive workflows
55- # and the tag/release is created on the correct commit
5654 - uses : actions/checkout@v4
5755 with :
5856 token : ${{ secrets.PAT_DISPATCH }}
7169 const repo = context.repo.repo;
7270 const errors = [];
7371
74- // 1. Check git tag
7572 try {
7673 await github.rest.git.getRef({ owner, repo, ref: `tags/${tag}` });
7774 errors.push(`Git tag '${tag}' already exists`);
8077 console.log(`✅ Git tag '${tag}' is available`);
8178 }
8279
83- // 2. Check GitHub Release
8480 try {
8581 await github.rest.repos.getReleaseByTag({ owner, repo, tag });
8682 errors.push(`GitHub Release '${tag}' already exists`);
@@ -89,33 +85,23 @@ jobs:
8985 console.log(`✅ GitHub Release '${tag}' is available`);
9086 }
9187
92- // 3. Check GitHub Packages (NuGet)
9388 try {
9489 const packages = await github.rest.packages.getAllPackageVersionsForPackageOwnedByOrg({
95- package_type: 'nuget',
96- package_name: repo,
97- org: owner
90+ package_type: 'nuget', package_name: repo, org: owner
9891 });
99- const exists = packages.data.some(p => p.name === version);
100- if (exists) {
92+ if (packages.data.some(p => p.name === version))
10193 errors.push(`NuGet package version '${version}' already exists on GitHub Packages`);
102- } else {
94+ else
10395 console.log(`✅ NuGet package version '${version}' is available`);
104- }
10596 } catch (e) {
106- if (e.status === 404) {
107- console.log(`✅ No package found yet (first publish)`);
108- } else {
109- console.warn(`⚠️ Could not check packages: ${e.message}`);
110- }
97+ if (e.status === 404) console.log(`✅ No package found yet (first publish)`);
98+ else console.warn(`⚠️ Could not check packages: ${e.message}`);
11199 }
112100
113- if (errors.length > 0) {
114- const msg = `❌ Version guard failed:\n${errors.map(e => ` - ${e}`).join('\n')}`;
115- core.setFailed(msg);
116- } else {
101+ if (errors.length > 0)
102+ core.setFailed(`❌ Version guard failed:\n${errors.map(e => ` - ${e}`).join('\n')}`);
103+ else
117104 console.log('\n✅ All version checks passed');
118- }
119105
120106 # ── Update Directory.Build.props ─────────────────
121107 - name : Read current version
@@ -129,15 +115,12 @@ jobs:
129115 run : |
130116 VERSION="${{ steps.params.outputs.version }}"
131117 CURRENT="${{ steps.current.outputs.version }}"
132-
133118 if [ "${VERSION}" = "${CURRENT}" ]; then
134119 echo "ℹ️ Version already set to ${VERSION}, no change needed"
135120 else
136121 sed -i "s|<Version>${CURRENT}</Version>|<Version>${VERSION}</Version>|" Directory.Build.props
137122 echo "✅ Updated Directory.Build.props: ${CURRENT} → ${VERSION}"
138123 fi
139-
140- # Verify
141124 grep '<Version>' Directory.Build.props
142125
143126 - name : Commit version bump
@@ -146,7 +129,6 @@ jobs:
146129 VERSION="${{ steps.params.outputs.version }}"
147130 git config user.name "github-actions[bot]"
148131 git config user.email "github-actions[bot]@users.noreply.github.com"
149-
150132 git add Directory.Build.props
151133 if git diff --cached --quiet; then
152134 echo "ℹ️ No changes to commit (version was already correct)"
@@ -168,7 +150,7 @@ jobs:
168150 "https://nuget.pkg.github.com/Payroll-Engine/index.json" \
169151 --name github \
170152 --username github-actions \
171- --password ${{ secrets.GITHUB_TOKEN }} \
153+ --password ${{ secrets.PAT_DISPATCH }} \
172154 --store-password-in-clear-text
173155
174156 - name : Restore
0 commit comments