Changed automation from GitHub to Forgejo + some small improvements
Some checks failed
Publish to Private NPM Registry / publish (push) Failing after 1m24s
Some checks failed
Publish to Private NPM Registry / publish (push) Failing after 1m24s
This commit is contained in:
parent
6ab565449a
commit
56be45cc94
1 changed files with 12 additions and 8 deletions
102
.forgejo/workflows/publish.yml
Normal file
102
.forgejo/workflows/publish.yml
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
name: Publish to Private NPM Registry
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: default
|
||||
|
||||
steps:
|
||||
# Checkout the repository
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# Set up NPM Auth Token
|
||||
- name: Set up NPM Auth Token
|
||||
run: echo "NODE_AUTH_TOKEN=${{ secrets.NPM_TOKEN }}" >> $GITHUB_ENV
|
||||
|
||||
# Set up Node.js
|
||||
- name: Set up Node.js version
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
# Taken from [Repo README](https://github.com/actions/setup-node#readme)
|
||||
#
|
||||
# > Version Spec of the version to use in SemVer notation.
|
||||
# > It also admits such aliases as lts/*, latest, nightly and canary builds
|
||||
# > Examples: 12.x, 10.15.1, >=10.15.0, lts/Hydrogen, 16-nightly, latest, node
|
||||
node-version: 'latest'
|
||||
|
||||
# Taken from [Repo README](https://github.com/actions/setup-node#readme)
|
||||
#
|
||||
# > Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file,
|
||||
# > and set up auth to read in from env.NODE_AUTH_TOKEN.
|
||||
# > Default: ''
|
||||
registry-url: 'https://npm.pkg.bridgemanaccessible.ca'
|
||||
|
||||
# Taken from [Repo README](https://github.com/actions/setup-node#readme)
|
||||
#
|
||||
# > Optional scope for authenticating against scoped registries.
|
||||
# > Will fall back to the repository owner when using the GitHub Packages registry (https://npm.pkg.github.com/).
|
||||
scope: '@BridgemanAccessible'
|
||||
|
||||
# Transpile/Build the package (TypeScript -> JavaScript)
|
||||
- name: Transpile/Build the package (TypeScript -> JavaScript)
|
||||
run: |
|
||||
# Install needed dependencies
|
||||
yarn install
|
||||
|
||||
# Build the package
|
||||
yarn build
|
||||
|
||||
- name: Determine Version and Increment (if needed)
|
||||
id: version_check
|
||||
run: |
|
||||
VERSION=$(node -p "require('./package.json').version")
|
||||
echo "Version: $VERSION"
|
||||
|
||||
NAME=$(node -p "require('./package.json').name")
|
||||
LATEST_VERSION=$(npm show $NAME version --registry https://npm.pkg.bridgemanaccessible.ca)
|
||||
echo "Latest version: $LATEST_VERSION"
|
||||
|
||||
if [ "$LATEST_VERSION" != "$VERSION" ]; then
|
||||
echo "Manually updated version detected: $VERSION"
|
||||
else
|
||||
NEW_VERSION=$(npm version patch --no-git-tag-version)
|
||||
echo "New version: $NEW_VERSION"
|
||||
echo "new_version=$NEW_VERSION" >> $GITHUB_ENV
|
||||
echo "version_changed=true" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Commit Version Change (if needed)
|
||||
if: steps.version_check.outputs.version_changed == 'true'
|
||||
run: |
|
||||
# Update remote URL to use the GITHUB_TOKEN for authentication
|
||||
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@git.bridgemanaccessible.ca/${{ github.repository }}.git
|
||||
|
||||
# Setup git user details for committing the version change
|
||||
git config user.name "Forgejo Actions"
|
||||
git config user.email "actions@git.bridgemanaccessible.ca"
|
||||
|
||||
# Commit the version change to the `package.json` file
|
||||
git add package.json
|
||||
git commit -m "[Forgejo Actions] Update version to ${{ env.new_version }}"
|
||||
|
||||
# Push the changes to the repository
|
||||
git push origin HEAD:main
|
||||
|
||||
# Publish to private NPM registry
|
||||
- name: Publish the package
|
||||
run: |
|
||||
# Copy over the files to the build output (`dist`) folder
|
||||
cp package.json dist/package.json
|
||||
cp README.md dist/README.md
|
||||
cp LICENSE dist/LICENSE
|
||||
|
||||
# Change directory to the build output (`dist`) folder
|
||||
cd dist
|
||||
|
||||
# Publish the package to the private NPM registry
|
||||
npm publish --registry http://npm.pkg.bridgemanaccessible.ca/
|
||||
Loading…
Add table
Add a link
Reference in a new issue