-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (69 loc) · 2.85 KB
/
release.yaml
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
name: Release
on:
push:
branches:
- main
jobs:
release:
runs-on: ubuntu-latest
env:
RELEASE_VERSION: null
MANIFEST_VERSION: null
EXTENSION_NAME: null
OUTDIR: .output
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Set extension name
run: |
NAME=$(jq -r '.name' package.json)
echo "EXTENSION_NAME=${NAME}" >> $GITHUB_ENV
- name: Check current release version
run: |
VERSION=$(git fetch --tags && git tag | xargs -n1 test -z && echo '0.0.0' || git rev-list --tags --topo-order --max-count=1 | xargs git describe --tags)
echo "RELEASE_VERSION=${VERSION}" >> $GITHUB_ENV
- name: Check package.json version
run: |
VERSION=$(jq -r '.version' package.json)
echo "MANIFEST_VERSION=${VERSION}" >> $GITHUB_ENV
- name: Push next release tag
if: ${{ success() && env.RELEASE_VERSION != env.MANIFEST_VERSION }}
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api \
repos/${{ github.repository}}/git/refs \
--method POST \
--field ref="refs/tags/${{ env.MANIFEST_VERSION}}" \
--field sha="${{ github.sha }}"
- uses: pnpm/action-setup@v4
if: ${{ success() && env.RELEASE_VERSION != env.MANIFEST_VERSION }}
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
if: ${{ success() && env.RELEASE_VERSION != env.MANIFEST_VERSION }}
with:
node-version-file: .node-version
cache: pnpm
- name: Install dependencies
if: ${{ success() && env.RELEASE_VERSION != env.MANIFEST_VERSION }}
run: pnpm install
- name: Build and zip the extension
if: ${{ success() && env.RELEASE_VERSION != env.MANIFEST_VERSION }}
run: pnpm run zip
- name: Create release
if: ${{ success() && env.RELEASE_VERSION != env.MANIFEST_VERSION }}
id: create_release
uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e # v1.1.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.MANIFEST_VERSION }}
release_name: Release ${{ env.MANIFEST_VERSION }}
- name: Upload release asset
if: ${{ success() && env.RELEASE_VERSION != env.MANIFEST_VERSION }}
uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5 # v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ env.OUTDIR }}/${{ env.EXTENSION_NAME }}-${{ env.MANIFEST_VERSION }}-chrome.zip
asset_name: ${{ env.EXTENSION_NAME }}-${{ env.MANIFEST_VERSION }}-chrome.zip
asset_content_type: application/zip