forked from dsebastien/obsidian-transcriber
-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (115 loc) · 5.03 KB
/
Copy pathrelease.yml
File metadata and controls
136 lines (115 loc) · 5.03 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 1.2.3)'
required: true
type: string
push:
tags:
- '*.*.*'
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-slim
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Setup Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Determine version and branch
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.version }}"
BRANCH="${{ github.ref_name }}"
else
# Triggered by tag push
VERSION="${{ github.ref_name }}"
# Find the branch that contains this tag
BRANCH=$(git branch -r --contains ${{ github.ref }} | grep -v HEAD | head -1 | sed 's/.*\///')
if [ -z "$BRANCH" ]; then
BRANCH="main"
fi
fi
# Strip 'v' prefix if present (for backwards compatibility)
VERSION="${VERSION#v}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
# Tag WITHOUT 'v' prefix per Obsidian plugin spec
echo "tag=$VERSION" >> $GITHUB_OUTPUT
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
echo "Target branch: $BRANCH"
- name: Checkout branch (when triggered by tag)
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
run: |
git checkout ${{ steps.version.outputs.branch }}
git pull origin ${{ steps.version.outputs.branch }}
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Update package.json version
run: bun run release:update-version ${{ steps.version.outputs.version }}
- name: Update manifest and versions.json
run: |
export npm_package_version=${{ steps.version.outputs.version }}
bun run release:version-bump
- name: Build for production
run: bun run build
- name: Generate changelog
run: bun run release:changelog
- name: Log changelog
run: |
echo "=== Changelog for ${{ steps.version.outputs.version }} ==="
head -100 CHANGELOG.md
- name: Format code
run: bun run format
- name: Commit release changes
run: |
git add package.json versions.json manifest.json CHANGELOG.md docs/release-notes.md
git commit -m "chore(release): ${{ steps.version.outputs.version }}" || echo "No changes to commit"
git push origin HEAD:${{ steps.version.outputs.branch }}
- name: Create and push tag (manual trigger only)
if: github.event_name == 'workflow_dispatch'
run: |
git tag -a ${{ steps.version.outputs.tag }} -m "Release ${{ steps.version.outputs.version }}"
git push origin ${{ steps.version.outputs.tag }}
- name: Create release zip
run: bun run release:zip
- name: Get package name
id: package
run: |
NAME=$(jq -r .name package.json)
echo "name=$NAME" >> $GITHUB_OUTPUT
- name: Extract changelog for release notes
id: changelog
run: |
# Extract the latest version section from CHANGELOG.md
NOTES=$(awk '/^## \[?[0-9]/{if(p) exit; p=1} p' CHANGELOG.md)
# Handle multi-line output
echo "notes<<EOF" >> $GITHUB_OUTPUT
echo "$NOTES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
name: ${{ steps.version.outputs.version }}
body: ${{ steps.changelog.outputs.notes }}
files: |
dist/${{ steps.package.outputs.name }}.zip
dist/main.js
dist/manifest.json
dist/styles.css
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}