-
-
Notifications
You must be signed in to change notification settings - Fork 40
76 lines (68 loc) · 2.61 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Creates a new GitHub Release when a tag is pushed
# See https://docs.obsidian.md/Plugins/Releasing/Submit+your+plugin#Step+2+Create+a+release
# Tag should be in the format of x.y.z without `v` prefix
# For example `1.0.0` is a valid tag, but `v1.0.0` is not
name: Release
permissions:
contents: write
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
env:
# IMPORTANT: Update this with the name of your plugin
PLUGIN_NAME: note-refactor-obsidian
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Build and zip
id: build
run: |
tag=${GITHUB_REF#refs/*/}
# Set tag as output for following steps
echo "tag=$tag" >> $GITHUB_OUTPUT
# Update version in manifest.json and package.json
jq --arg tag "$tag" '.version = $tag' manifest.json >> tmp.$$.json && mv tmp.$$.json manifest.json
jq --arg tag "$tag" '.version = $tag' package.json >> tmp.$$.json && mv tmp.$$.json package.json
# Build and zip release
npm install
npm run build
mkdir ${{ env.PLUGIN_NAME }}
cp styles.css dist/main.js manifest.json ${{ env.PLUGIN_NAME }}
zip -r ${{ env.PLUGIN_NAME }}.zip ${{ env.PLUGIN_NAME }}
- name: Commit version changes
uses: EndBug/add-and-commit@1bad3abcf0d6ec49a5857d124b0bfb52dc7bb081
with:
default_author: github_actor
add: 'manifest.json package.json package-lock.json'
message: 'Release ${{ steps.build.outputs.tag }}'
push: 'origin HEAD:${{ github.event.repository.default_branch }} --force'
# Override existing tag with new tag that has version bump
tag: '${{ steps.build.outputs.tag }} --force'
tag_push: '--force'
- name: Release with files
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
with:
name: ${{ steps.build.outputs.tag }}
body: "*Release of ${{ env.PLUGIN_NAME }} v${{ steps.build.outputs.tag }} auto-created by [release.yml](.github/workflows/release.yml)*"
files: |
${{ env.PLUGIN_NAME }}.zip
main.js
manifest.json
styles.css
- name: Upload artifacts for debugging
uses: actions/upload-artifact@v3
with:
name: ${{ env.PLUGIN_NAME }}
path: |
${{ env.PLUGIN_NAME }}.zip
main.js
manifest.json
styles.css