Skip to content

Commit

Permalink
Allow to manually publish new versions (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aviortheking authored Dec 12, 2023
1 parent 7dc88c9 commit 5ddb9c7
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 8 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = tab
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
10 changes: 10 additions & 0 deletions .github/workflows/build_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,41 @@ jobs:
with:
persist-credentials: false
fetch-depth: 0

- uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://registry.npmjs.org/

- name: Prepare Upgrade script
run: npm ci

- name: Upgrade
id: upgrade
run: node upgrade.js
continue-on-error: true

- name: Install
run: npm i
if: steps.upgrade.outcome == 'success' && steps.upgrade.conclusion == 'success'

- name: Build
run: npm run build
if: steps.upgrade.outcome == 'success' && steps.upgrade.conclusion == 'success'

- name: Publish on NPM
run: npm publish
if: steps.upgrade.outcome == 'success' && steps.upgrade.conclusion == 'success'
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

- name: Commit files
run: |
git config --local user.email "[email protected]"
git config --local user.name "Dzeio BOT"
git commit -a -m "bump from remote"
if: steps.upgrade.outcome == 'success' && steps.upgrade.conclusion == 'success'

- name: Push changes
uses: ad-m/github-push-action@master
with:
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

# ENV needed:
# GIT_TOKEN
# NPM_TOKEN
name: Manual publish

on:
workflow_dispatch:

jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0

- uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://registry.npmjs.org/

- name: Install
run: npm i

- name: Build
run: npm run build

- name: Publish on NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
10 changes: 4 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lucide-astro",
"version": "0.294.0",
"version": "0.294.1",
"description": "Get your Lucide icons right into your Astro project",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand All @@ -26,7 +26,8 @@
"author": "Aviortheking",
"license": "MIT",
"devDependencies": {
"lucide-static": "0.294.0"
"lucide-static": "0.294.0",
"semver": "^7.5.4"
},
"peerDependencies": {
"astro": ">=2.7.1"
Expand Down
8 changes: 8 additions & 0 deletions upgrade.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from 'node:fs/promises'
import semver from 'semver'
/**
* Javascript script linked to `upgrade.sh`
*/
Expand All @@ -10,6 +11,7 @@ const upstreamPackage = 'lucide-static'

const check = await fetch(`https://registry.npmjs.com/${upstreamPackage}`).then((it) => it.json())
const newVersion = check['dist-tags']?.latest

if (!newVersion) {
console.error('no new version found :(')
process.exit(1)
Expand All @@ -18,6 +20,12 @@ const upstreamPackage = 'lucide-static'
console.log('no diff in version, ending')
process.exit(1)
}

if (!semver.gt(newVersion, pkgVersion)) {
console.log('package version', pkgVersion, 'higher than upstream version', newVersion, 'skipping update')
process.exit(1)
}

console.log('diff in version, update needed')
pkg.version = newVersion
pkg.devDependencies[upstreamPackage] = newVersion
Expand Down

0 comments on commit 5ddb9c7

Please sign in to comment.