-
Notifications
You must be signed in to change notification settings - Fork 1
96 lines (84 loc) · 2.74 KB
/
obsidian-plugin-github-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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: Create Obsidian Plugin GitHub Release
on:
push:
tags:
- '[0-9]*'
jobs:
build:
name: Create Release
runs-on: ubuntu-latest
env:
ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN || secrets.GITHUB_TOKEN }}
IS_VALID_COMMIT: false
TAG_NAME: ''
ZIP_NAME: 'archive.zip'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Log Token Type
run: |
if [ ${{ env.ACCESS_TOKEN }} == ${{ secrets.GITHUB_TOKEN }} ]; then
echo "🗝️ Authenticated with GitHub Token"
else
echo "🔑 Authenticated with Personal Access token"
fi
- name: Validate Tag and Branch
id: validation
run: |
TAG=$(git tag --contains HEAD | grep '^[0-9]' | head -n 1)
echo "🏷️ Tag for commit is: $TAG"
BRANCH=$(git branch -r --contains tags/${GITHUB_REF_NAME} | grep 'origin/main' | xargs)
if [[ -z "$BRANCH" ]]; then
echo "🚨 Tag is not on main branch"
else
echo "🕊️ Current branch is: $BRANCH"
fi
if [[ -z "$TAG" || -z "$BRANCH" ]]; then
echo "IS_VALID_COMMIT=false" >> $GITHUB_ENV
echo "TAG_NAME=''" >> $GITHUB_ENV
else
echo "IS_VALID_COMMIT=true" >> $GITHUB_ENV
echo "TAG_NAME=$TAG" >> $GITHUB_ENV
fi
- name: Setup Pnpm
uses: pnpm/action-setup@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
- run: pnpm install
- name: Build Plugin
run: pnpm run build
- name: Zip Artifacts
run: |
mkdir -p ./zip
zip -r "./zip/${GITHUB_REPOSITORY##*/}-${TAG_NAME}.zip" dist/
- name: Release Notes
if: env.IS_VALID_COMMIT == 'true'
id: release-notes
uses: kitschpatrol/github-action-release-changelog@v2
- name: Release
if: env.IS_VALID_COMMIT == 'true'
id: release
uses: kitschpatrol/github-action-release@v2
with:
token: ${{ env.ACCESS_TOKEN }}
draft: false
prerelease: false
fail_on_unmatched_files: true
name: ${{ env.TAG_NAME }}
tag_name: ${{ env.TAG_NAME }}
body: |
${{ steps.release-notes.outputs.changelog }}
files: |
dist/*
zip/*
- name: Log Release Details
if: env.IS_VALID_COMMIT == 'true'
run: |
echo "📦 Successfully released: ${{ env.TAG_NAME }}"
echo "🔗 Release URL: ${{ steps.release.outputs.url }}"
echo "🪪 Release ID: ${{ steps.release.outputs.id }}"