mirror of
https://github.com/lenalebt/obsidian-pocketbook-cloud-highlight-importer.git
synced 2026-07-22 07:40:24 +00:00
Adds an automatic release process
This commit is contained in:
parent
f2a4d5c02a
commit
589125ae8b
2 changed files with 121 additions and 0 deletions
76
.github/workflows/release.yml
vendored
Normal file
76
.github/workflows/release.yml
vendored
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
name: Release Obsidian plugin
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
env:
|
||||
PLUGIN_NAME: pocketbook-cloud-highlight-importer
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: '19.x'
|
||||
|
||||
- name: Build
|
||||
id: build
|
||||
run: |
|
||||
npm install
|
||||
npm run build
|
||||
mkdir ${{ env.PLUGIN_NAME }}
|
||||
cp main.js manifest.json ${{ env.PLUGIN_NAME }}
|
||||
zip -r ${{ env.PLUGIN_NAME }}.zip ${{ env.PLUGIN_NAME }}
|
||||
ls
|
||||
echo "::set-output name=tag_name::$(git tag --sort version:refname | tail -n 1)"
|
||||
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
VERSION: ${{ github.ref }}
|
||||
with:
|
||||
tag_name: ${{ github.ref }}
|
||||
release_name: ${{ github.ref }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
|
||||
- name: Upload zip file
|
||||
id: upload-zip
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ./${{ env.PLUGIN_NAME }}.zip
|
||||
asset_name: ${{ env.PLUGIN_NAME }}-${{ steps.build.outputs.tag_name }}.zip
|
||||
asset_content_type: application/zip
|
||||
|
||||
- name: Upload main.js
|
||||
id: upload-main
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ./main.js
|
||||
asset_name: main.js
|
||||
asset_content_type: text/javascript
|
||||
|
||||
- name: Upload manifest.json
|
||||
id: upload-manifest
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ./manifest.json
|
||||
asset_name: manifest.json
|
||||
asset_content_type: application/json
|
||||
45
release.sh
Executable file
45
release.sh
Executable file
|
|
@ -0,0 +1,45 @@
|
|||
#!/bin/bash
|
||||
# cd to git root https://stackoverflow.com/a/38843585
|
||||
r=$(git rev-parse --git-dir) && r=$(cd "$r" && pwd)/ && cd "${r%%/.git/*}"
|
||||
|
||||
if [[ ! -f "./manifest.json" ]] ; then
|
||||
echo "manifest.json does not exist yet"
|
||||
return
|
||||
fi
|
||||
if [[ ! -f "./.github/workflows/release.yml" ]] ; then
|
||||
echo "/.github/workflows/release.yml does not exist yet"
|
||||
return
|
||||
fi
|
||||
|
||||
# get version number from the manifest of the latest release
|
||||
repoURL=$(git remote -v | grep git@github.com | grep fetch | head -n1 | cut -f2 | cut -d' ' -f1 | sed -e's/:/\//' -e 's/git@/https:\/\//' -e 's/\.git//' )
|
||||
manifestURL="$repoURL"/releases/latest/download/manifest.json
|
||||
lastVersion=$(curl -sL "$manifestURL" | grep "version" | cut -d\" -f4)
|
||||
echo "last version: $lastVersion"
|
||||
|
||||
# Ask for new version number
|
||||
echo -n "next version: "
|
||||
read nextVersion
|
||||
|
||||
# set version number in `manifest.json`
|
||||
sed -E -i '' "s/\"version\".*/\"version\": \"$nextVersion\",/" "manifest.json"
|
||||
|
||||
# set version number in `package.json`
|
||||
sed -E -i '' "s/\"version\".*/\"version\": \"$nextVersion\",/" "package.json"
|
||||
|
||||
# add version number in `versions.json`, assuming same compatibility
|
||||
cat "versions.json" | egrep -v "^$" | grep -v "}" | sed -e '$ d' > temp
|
||||
minObsidianVersion=$(cat "versions.json" | egrep -v "^$" | grep -v "}" | tail -n1 | cut -d\" -f4)
|
||||
echo " \"$lastVersion\": \"$minObsidianVersion\"," >> temp
|
||||
echo " \"$nextVersion\": \"$minObsidianVersion\"" >> temp
|
||||
echo "}" >> temp
|
||||
mv temp versions.json
|
||||
|
||||
# push the manifest and versions JSONs
|
||||
git add -A
|
||||
git commit -m "version bump to $nextVersion"
|
||||
git push
|
||||
|
||||
# trigger the release action
|
||||
git tag "$nextVersion"
|
||||
git push origin --tags
|
||||
Loading…
Reference in a new issue