-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
123 lines (113 loc) · 3.77 KB
/
action.yml
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: "update-chrome-extension-version-action"
description: "Automatically update chrome extension version action"
inputs:
github_token:
description: "GitHub access token"
required: true
default: ""
manifest_file_path:
description: "File path of manifest file with version"
required: false
default: "manifest.json"
upload_chrome_web_store:
description: "Automatically upload chrome web store"
required: false
default: false
chrome_extension_id:
description: "Chrome extension id"
required: false
default: ""
google_client_id:
description: "GCP client id"
required: false
default: ""
google_client_secret:
description: "GCP client secret"
required: false
default: ""
refresh_token:
description: "Refresh token"
required: false
default: ""
zip_file_name:
description: "Zip file name"
required: false
default: "output"
out_dir:
description: "Output directory path"
required: false
default: "./dist"
create_release_note:
description: "Automatically create release notes"
required: false
default: false
runs:
using: "composite"
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 8
- name: Install modules
run: pnpm i
shell: bash
- name: Get current version
id: get-current-version
run: |
result=$(npx dot-json@1 package.json version)
echo "version=${result}" >> $GITHUB_OUTPUT
shell: bash
- name: Get next version
id: get-next-version
uses: mmrakt/[email protected]
with:
layer: |
${{
contains(github.event.pull_request.labels.*.name, 'release:major') && 'major' ||
contains(github.event.pull_request.labels.*.name, 'release:minor') && 'minor' ||
'patch'
}}
version: ${{ steps.get-current-version.outputs.version }}
- name: Configuration GitHub
if: steps.diff.outputs.changed == '0'
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git remote set-url origin https://github-actions:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.github_token }}
- name: Update versioning
run: |
npx dot-json@1 ${{ inputs.manifest_file_path }} version "${{ steps.get-next-version.outputs.version }}"
npx dot-json@1 package.json version "${{ steps.get-next-version.outputs.version }}"
shell: bash
- name: Push diff
run: |
git add .
git commit -m ":thumbsup: Bump up to v$(grep version package.json | awk -F \" '{print $4}')"
git push origin HEAD
shell: bash
- name: Build and zip
run: |
pnpm build
zip -r ${{ inputs.zip_file_name }}.zip ${{ inputs.out_dir }}
shell: bash
if: ${{ inputs.create_release_note == 'true' || inputs.upload_chrome_web_store == 'true' }}
- name: Upload Chrome web store
run: |
npx chrome-webstore-upload-cli@2 upload --source ${{ inputs.zip_file_name }}.zip --auto-publish
env:
EXTENSION_ID: ${{ inputs.chrome_extension_id }}
CLIENT_ID: ${{ inputs.google_client_id }}
CLIENT_SECRET: ${{ inputs.google_client_secret }}
REFRESH_TOKEN: ${{ inputs.refresh_token }}
if: ${{ inputs.upload_chrome_web_store == 'true' }}
shell: bash
- name: Create release draft
uses: softprops/action-gh-release@v1
with:
tag_name: "v${{ steps.get-next-version.outputs.version }}"
generate_release_notes: true
files: ${{ inputs.zip_file_name }}
if: ${{ inputs.create_release_note == 'true' }}