@@ -3,6 +3,12 @@ name: CI
33on :
44 push :
55 workflow_call :
6+ workflow_dispatch :
7+ inputs :
8+ release_version :
9+ description : Version to publish to npm and GitHub Packages
10+ required : true
11+ type : string
612
713jobs :
814 lint :
2026
2127 - name : Build Version
2228 id : version
29+ env :
30+ VERSION_OVERRIDE : ${{ inputs.release_version }}
2331 run : |
24- dotnet tool install --global minver-cli --version 7.0.0
25- version=$(minver --tag-prefix v)
32+ if [ -n "$VERSION_OVERRIDE" ]; then
33+ version="$VERSION_OVERRIDE"
34+ else
35+ dotnet tool install --global minver-cli --version 7.0.0
36+ version=$(minver --tag-prefix v)
37+ fi
2638 echo "version=$version" >> $GITHUB_OUTPUT
2739 echo "### Version: $version" >> $GITHUB_STEP_SUMMARY
2840
8698 - name : Build NPM Package
8799 run : deno task build --set-version ${{ needs.lint.outputs.version }}
88100
101+ - name : Add NPM Package Metadata
102+ env :
103+ REPOSITORY_URL : https://github.com/${{ github.repository }}
104+ run : |
105+ package_dir=$(mktemp -d)
106+ tar -xzf fetchclient.tgz -C "$package_dir"
107+ PACKAGE_JSON="$package_dir/package/package.json" deno eval '
108+ const path = Deno.env.get("PACKAGE_JSON");
109+ const repositoryUrl = Deno.env.get("REPOSITORY_URL");
110+ const packageJson = JSON.parse(await Deno.readTextFile(path));
111+ packageJson.repository = { type: "git", url: repositoryUrl };
112+ await Deno.writeTextFile(path, `${JSON.stringify(packageJson, null, 2)}\n`);
113+ '
114+ tar -czf fetchclient.tgz -C "$package_dir" package
115+
89116 - name : Show NPM Package
90117 run : tar -xOf fetchclient.tgz package/package.json
91118
@@ -97,25 +124,25 @@ jobs:
97124 scope : " @foundatiofx"
98125
99126 - name : Publish Release Package
100- if : startsWith(github.ref, 'refs/tags/v')
127+ if : startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
101128 run : npm publish fetchclient.tgz --provenance --access public
102129
103130 - name : Setup GitHub CI Node.js environment
104- if : github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
131+ if : github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
105132 uses : actions/setup-node@v7
106133 with :
107134 node-version : " 24.x"
108135 registry-url : " https://npm.pkg.github.com"
109136 scope : " @foundatiofx"
110137
111138 - name : Push GitHub CI Packages
112- if : github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
139+ if : github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
113140 run : |
114141 package="@foundatiofx/fetchclient@${{ needs.lint.outputs.version }}"
115142 if npm view "$package" version --registry https://npm.pkg.github.com > /dev/null 2>&1; then
116143 echo "$package already exists in GitHub Packages; skipping publish."
117144 else
118- npm publish fetchclient.tgz --tag ${{ startsWith(github.ref, 'refs/tags/v') && 'latest' || 'next' }} --access public
145+ npm publish fetchclient.tgz --tag ${{ ( startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch ') && 'latest' || 'next' }} --access public
119146 fi
120147 env :
121148 NODE_AUTH_TOKEN : ${{secrets.GITHUB_TOKEN}}
0 commit comments