Skip to content

Commit

Permalink
prep for action update
Browse files Browse the repository at this point in the history
  • Loading branch information
TfTHacker committed Apr 4, 2024
1 parent dae7b35 commit b70fce1
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Release Obsidian plugin

on:
push:
tags:
- '*'

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '21.x'

- name: Build plugin
run: |
npm install
npm run build
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tag="${GITHUB_REF#refs/tags/}"
gh release create "$tag" \
--title="$tag" \
build/main.js manifest.json styles.css
6 changes: 6 additions & 0 deletions DEV_NOTES.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Updating the version

1. update pacakage.json version number
2. npm run version (updates the manifest and version file)
3. commit repo
4. npm run githubaction (commits the version number tag to the repo and pushes it, which kicks of the github action to prepare the release)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"dev": "node esbuild.config.mjs",
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
"version": "node version-bump.mjs && git add manifest.json versions.json",
"version": "node version-bump.mjs",
"lint:check": "eslint --ext .ts,.tsx .",
"lint:fix": "eslint --fix --ext .ts,.tsx .",
"format:check": "prettier --check .",
Expand Down
14 changes: 14 additions & 0 deletions version-bump.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { readFileSync, writeFileSync } from 'fs';

const targetVersion = process.env.npm_package_version;

// read minAppVersion from manifest.json and bump version to target version
let manifest = JSON.parse(readFileSync('manifest.json', 'utf8'));
const { minAppVersion } = manifest;
manifest.version = targetVersion;
writeFileSync('manifest.json', JSON.stringify(manifest, null, '\t'));

// update versions.json with target version and minAppVersion from manifest.json
let versions = JSON.parse(readFileSync('versions.json', 'utf8'));
versions[targetVersion] = minAppVersion;
writeFileSync('versions.json', JSON.stringify(versions, null, '\t'));

0 comments on commit b70fce1

Please sign in to comment.