-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (51 loc) · 2.04 KB
/
Copy pathauto-release.yml
File metadata and controls
59 lines (51 loc) · 2.04 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
name: Auto Release on Dependency Update
on:
push:
branches:
- main
paths:
- 'package.json'
- 'pnpm-lock.yaml'
jobs:
check-and-release:
name: Create Release Tag
runs-on: ubuntu-latest
if: "contains(github.event.head_commit.message, 'chore(deps): swarm-cli')"
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Get swarm-cli version
id: version
run: |
SWARM_VERSION=$(node -e "console.log(require('./package.json').dependencies['@ethersphere/swarm-cli'])")
echo "swarm_version=$SWARM_VERSION" >> $GITHUB_OUTPUT
echo "tag_name=v$SWARM_VERSION" >> $GITHUB_OUTPUT
echo "Swarm CLI version: $SWARM_VERSION"
- name: Check if tag exists
id: check_tag
run: |
if git rev-parse "v${{ steps.version.outputs.swarm_version }}" >/dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "Tag v${{ steps.version.outputs.swarm_version }} already exists"
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "Tag v${{ steps.version.outputs.swarm_version }} does not exist"
fi
- name: Create and push tag
if: steps.check_tag.outputs.exists == 'false'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "v${{ steps.version.outputs.swarm_version }}" -m "Release swarm-cli v${{ steps.version.outputs.swarm_version }}"
git push origin "v${{ steps.version.outputs.swarm_version }}"
echo "✅ Created and pushed tag v${{ steps.version.outputs.swarm_version }}"
- name: Tag already exists
if: steps.check_tag.outputs.exists == 'true'
run: |
echo "ℹ️ Tag v${{ steps.version.outputs.swarm_version }} already exists, skipping release creation"