-
Notifications
You must be signed in to change notification settings - Fork 1
106 lines (91 loc) · 3.56 KB
/
release.yml
File metadata and controls
106 lines (91 loc) · 3.56 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
name: Release
on:
push:
branches:
- main
jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v4
with:
version: 10.20.0
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build packages
run: pnpm build
- name: Commit dist folder (if changed)
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add packages/scripts/dist/
if git diff --staged --quiet; then
echo "No changes to dist folder"
else
git commit -m "chore: build scripts package"
git push
fi
- name: Create Release Pull Request or Publish
id: changesets
uses: changesets/action@v1
with:
publish: pnpm changeset publish
version: pnpm changeset version
commit: 'chore: version packages'
title: 'chore: version packages'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get Scripts Package Version
if: steps.changesets.outputs.published == 'true'
id: version
run: |
VERSION=$(grep -o '"version": "[^"]*"' packages/scripts/package.json | cut -d'"' -f4)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
echo "Released version: $VERSION"
- name: Create Git Tag
if: steps.changesets.outputs.published == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "${{ steps.version.outputs.tag }}" -m "Release ${{ steps.version.outputs.tag }}"
git push origin "${{ steps.version.outputs.tag }}"
- name: Create GitHub Release for Scripts
if: steps.changesets.outputs.published == 'true'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version.outputs.tag }}
name: Scripts Release ${{ steps.version.outputs.tag }}
body: |
Automated release of scripts package.
**Version:** ${{ steps.version.outputs.version }}
**jsdelivr URLs:**
- Latest from this version: `https://cdn.jsdelivr.net/gh/${{ github.repository }}@${{ steps.version.outputs.tag }}/packages/scripts/dist/index.js`
- Latest from major version: `https://cdn.jsdelivr.net/gh/${{ github.repository }}@${{ steps.version.outputs.version }}.*/packages/scripts/dist/index.js`
- Specific commit: `https://cdn.jsdelivr.net/gh/${{ github.repository }}@${{ github.sha }}/packages/scripts/dist/index.js`
**Usage in HTML:**
```html
<script defer src="https://cdn.jsdelivr.net/gh/${{ github.repository }}@${{ steps.version.outputs.tag }}/packages/scripts/dist/index.js"></script>
```
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Scripts Artifacts
if: steps.changesets.outputs.published == 'true'
uses: actions/upload-artifact@v4
with:
name: scripts-dist
path: packages/scripts/dist/**
retention-days: 90