Skip to content

Commit 184b21a

Browse files
committed
Add publish workflow
1 parent 727c41c commit 184b21a

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

.github/workflows/publish.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Publish GitHub Action
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*' # Matches version tags like v1.0.0
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: 20
20+
21+
- name: Install dependencies
22+
run: npm install
23+
24+
- name: Run tests
25+
run: npm test
26+
27+
- name: Build action
28+
run: npm run build
29+
30+
- name: Create GitHub Release
31+
id: create_release
32+
uses: actions/create-release@v1
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
with:
36+
tag_name: ${{ github.ref_name }}
37+
release_name: Release ${{ github.ref_name }}
38+
draft: false
39+
prerelease: false
40+
41+
- name: Publish to GitHub Marketplace
42+
run: |
43+
git config user.name "GitHub Actions"
44+
git config user.email "actions@github.com"
45+
git tag -fa ${{ github.ref_name }} -m "Release ${{ github.ref_name }}"
46+
git push origin ${{ github.ref_name }}
47+
48+
- name: Update major version tag
49+
if: startsWith(github.ref, 'refs/tags/v')
50+
run: |
51+
MAJOR_VERSION=$(echo ${{ github.ref_name }} | sed -E 's/^v([0-9]+)\..*/v\1/')
52+
git tag -fa $MAJOR_VERSION -m "Update $MAJOR_VERSION tag to ${{ github.ref_name }}"
53+
git push origin $MAJOR_VERSION

0 commit comments

Comments
 (0)