Skip to content

Commit 150a512

Browse files
committed
fix: fix workflow and update README.md
1 parent 15b30de commit 150a512

2 files changed

Lines changed: 100 additions & 2 deletions

File tree

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# .github/workflows/release.yml
2+
name: Create Release
3+
4+
on:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v5
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v6
23+
with:
24+
node-version: '20'
25+
26+
- name: Install dependencies
27+
run: npm install
28+
29+
- name: Build
30+
run: npm run build
31+
32+
- name: Get version from package.json
33+
id: package_version
34+
run: |
35+
VERSION=$(node -p "require('./package.json').version")
36+
echo "version=$VERSION" >> $GITHUB_OUTPUT
37+
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
38+
39+
- name: Check if tag exists
40+
id: check_tag
41+
run: |
42+
if git rev-parse "v${{ steps.package_version.outputs.version }}" >/dev/null 2>&1; then
43+
echo "exists=true" >> $GITHUB_OUTPUT
44+
else
45+
echo "exists=false" >> $GITHUB_OUTPUT
46+
fi
47+
48+
- name: Configure Git
49+
if: steps.check_tag.outputs.exists == 'false'
50+
run: |
51+
git config user.name "github-actions[bot]"
52+
git config user.email "github-actions[bot]@users.noreply.github.com"
53+
54+
- name: Delete and recreate release branch
55+
if: steps.check_tag.outputs.exists == 'false'
56+
run: |
57+
# Check if release branch exists remotely
58+
if git ls-remote --heads origin release | grep -q release; then
59+
echo "Deleting existing release branch..."
60+
git push origin --delete release
61+
fi
62+
63+
# Create fresh release branch from master
64+
git checkout -b release
65+
66+
# Add built files
67+
git add -f build/
68+
69+
# Commit built files
70+
git commit -m "build: release v${{ steps.package_version.outputs.version }}"
71+
72+
# Force push release branch
73+
git push -f origin release
74+
75+
- name: Create Git tag on release branch
76+
if: steps.check_tag.outputs.exists == 'false'
77+
run: |
78+
git tag -a "v${{ steps.package_version.outputs.version }}" -m "Release v${{ steps.package_version.outputs.version }}"
79+
git push origin "v${{ steps.package_version.outputs.version }}"
80+
81+
- name: Create Release
82+
if: steps.check_tag.outputs.exists == 'false'
83+
uses: softprops/action-gh-release@v1
84+
with:
85+
tag_name: v${{ steps.package_version.outputs.version }}
86+
name: Release v${{ steps.package_version.outputs.version }}
87+
draft: false
88+
prerelease: false
89+
generate_release_notes: true
90+
target_commitish: release
91+
env:
92+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93+
94+
- name: Skip - Release already exists
95+
if: steps.check_tag.outputs.exists == 'true'
96+
run: |
97+
echo "Release v${{ steps.package_version.outputs.version }} already exists. Skipping release creation."
98+
echo "To create a new release, bump the version in package.json"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ This package is highly experimental. Not recommended for production usage. Feel
1010

1111
- Install this package
1212
```sh
13-
npm install git+https://github.com/xnicecraft/adonisjs-socketio.git
13+
npm install https://github.com/xnicecraft/adonisjs-socketio#<version from release>
1414
```
1515
- Configure the package
1616
```sh
17-
node ace configure "@xnicecraft/adonisjs-socketio"
17+
node ace configure @xnicecraft/adonisjs-socketio
1818
```
1919
- And file start/websocket.ts and config/websocket.ts will be created
2020

0 commit comments

Comments
 (0)