Skip to content

Commit 0305094

Browse files
committed
ci: Add GitHub Actions workflow for release creation
1 parent ac0c42c commit 0305094

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

.github/workflows/release.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Create Release
2+
3+
# Trigger this workflow when a new tag starting with 'v' (e.g., v1.0.0) is pushed
4+
on:
5+
push:
6+
tags:
7+
- 'v*' # Matches tags like v1.0, v2.3.4
8+
9+
# Environment variables to make asset names easier to manage
10+
env:
11+
PLUGIN_NAME: obsidian-solidtime-integration # Change if needed
12+
13+
jobs:
14+
build-release:
15+
name: Build and Release Plugin
16+
runs-on: ubuntu-latest # Use the latest Ubuntu runner
17+
18+
steps:
19+
# 1. Checkout the repository code at the specific tag
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
# 2. Setup Node.js environment
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: '20.x' # Specify your Node.js version
28+
cache: 'npm' # Cache npm dependencies
29+
30+
# 3. Install dependencies
31+
- name: Install dependencies
32+
run: npm ci # Use 'ci' for cleaner installs in CI environments
33+
34+
# 4. Build the plugin (this generates main.js)
35+
- name: Build plugin
36+
run: npm run build
37+
38+
# --- Prepare Assets ---
39+
# We need main.js (built), styles.css, and manifest.json
40+
41+
# 5. Create ZIP archive
42+
- name: Create ZIP package
43+
# Extract version from the tag (e.g., v1.2.3 -> 1.2.3)
44+
run: |
45+
TAG_VERSION=${GITHUB_REF_NAME#v}
46+
echo "TAG_VERSION=${TAG_VERSION}" >> $GITHUB_ENV
47+
zip ${{ env.PLUGIN_NAME }}-${TAG_VERSION}.zip main.js manifest.json styles.css
48+
shell: bash # Use bash for string manipulation
49+
50+
# 6. Create GitHub Release and Upload Assets
51+
- name: Create Release
52+
uses: softprops/action-gh-release@v2 # Use a popular action for creating releases
53+
with:
54+
# Use the version extracted from the tag for the release name/tag
55+
tag_name: ${{ github.ref_name }}
56+
name: Release ${{ env.TAG_VERSION }}
57+
# Body can be empty, manually edited later, or generated from changelog (advanced)
58+
# body: |
59+
# Release notes for version ${{ env.TAG_VERSION }}
60+
# - Feature A
61+
# - Bugfix B
62+
# Mark as pre-release if tag contains 'beta', 'alpha', etc. (optional)
63+
prerelease: ${{ contains(github.ref, 'beta') || contains(github.ref, 'alpha') || contains(github.ref, 'rc') }}
64+
files: | # List files to upload as assets
65+
main.js
66+
manifest.json
67+
styles.css
68+
${{ env.PLUGIN_NAME }}-${{ env.TAG_VERSION }}.zip # Upload the ZIP archive
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Required for the action to interact with GitHub API

0 commit comments

Comments
 (0)