Skip to content

Commit b14363d

Browse files
committed
👷 ci: add github actions to build & release the plugin
1 parent 07892a8 commit b14363d

File tree

4 files changed

+2171
-38
lines changed

4 files changed

+2171
-38
lines changed

.github/workflows/release.yml

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release:
10+
name: Release
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: '20.8.1'
21+
22+
- name: Cache node_modules
23+
uses: actions/cache@v3
24+
with:
25+
path: node_modules
26+
key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json') }}
27+
restore-keys: |
28+
${{ runner.os }}-node-modules-
29+
30+
- name: Install dependencies
31+
if: steps.cache.outputs.cache-hit != 'true'
32+
run: npm install --legacy-peer-deps
33+
34+
- name: Build application
35+
run: npm run build
36+
37+
- name: Bump version and release
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
run: npx semantic-release
41+
42+
- name: Retrieve plugin version and name
43+
id: get_version
44+
run: |
45+
echo "PLUGIN_VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV
46+
echo "PLUGIN_NAME=$(node -p -e "require('./package.json').name")" >> $GITHUB_ENV
47+
48+
- name: Zip build files in a temporary directory
49+
run: |
50+
mkdir -p /tmp/build
51+
zip -r /tmp/build/${{ env.PLUGIN_NAME }}-${{ env.PLUGIN_VERSION }}.zip ./build
52+
53+
- name: Create release and attach zip file
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
run: |
57+
TAG=v${{ env.PLUGIN_VERSION }}
58+
RELEASE_TITLE="v${{ env.PLUGIN_VERSION }}"
59+
DESCRIPTION="Release for plugin ${{ env.PLUGIN_NAME }}. Version: ${{ env.PLUGIN_VERSION }}. [Download latest build](https://github.com/${{ github.repository }}/raw/builds/${{ env.PLUGIN_NAME }}-${{ env.PLUGIN_VERSION }}.zip)"
60+
61+
# Create a GitHub release
62+
gh release create $TAG /tmp/build/${{ env.PLUGIN_NAME }}-${{ env.PLUGIN_VERSION }}.zip \
63+
--title "$RELEASE_TITLE" \
64+
--notes "$DESCRIPTION"
65+
shell: bash

.releaserc

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"branches": ["main"],
3+
"plugins": [
4+
[
5+
"@semantic-release/commit-analyzer",
6+
{
7+
"preset": "conventionalcommits",
8+
"parserOpts": {
9+
"headerPattern": "^[^a-zA-Z0-9]*(\\w*)(?:\\((.*)\\))?:\\s*(.*)$",
10+
"headerCorrespondence": ["type", "scope", "subject"]
11+
}
12+
}
13+
],
14+
"@semantic-release/changelog",
15+
[
16+
"@semantic-release/npm",
17+
{
18+
"npmPublish": false
19+
}
20+
],
21+
[
22+
"@semantic-release/github",
23+
{
24+
"assets": [
25+
{"path": "*.zip", "label": "Build"}
26+
]
27+
}
28+
],
29+
[
30+
"@semantic-release/git",
31+
{
32+
"assets": ["package.json", "CHANGELOG.md"],
33+
"message": "💥 chore: ${nextRelease.version} [skip ci]"
34+
}
35+
]
36+
],
37+
"publish": false
38+
}
39+

package.json

+8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
2+
"name": "figma-sprite-generator",
3+
"version": "1.0.0",
24
"dependencies": {
35
"@create-figma-plugin/ui": "^3.2.0",
46
"@create-figma-plugin/utilities": "^3.2.0",
@@ -13,6 +15,12 @@
1315
"@typescript-eslint/eslint-plugin": "^7.15.0",
1416
"@typescript-eslint/parser": "^7.15.0",
1517
"concurrently": ">=8",
18+
"@semantic-release/changelog": "^6.0.3",
19+
"@semantic-release/commit-analyzer": "^13.0.0",
20+
"@semantic-release/git": "^10.0.1",
21+
"@semantic-release/github": "^11.0.0",
22+
"@semantic-release/npm": "^12.0.1",
23+
"conventional-changelog-conventionalcommits": "^8.0.0",
1624
"eslint": "^8.57.0",
1725
"eslint-config-prettier": "^9.1.0",
1826
"eslint-import-resolver-typescript": "^3.6.1",

0 commit comments

Comments
 (0)