44 push :
55 branches : [ master, main ]
66 pull_request :
7+ types : [closed]
78 branches : [ master, main ]
89
910jobs :
1011 test :
12+ permissions :
13+ contents : read
14+ pull-requests : write
15+
1116 runs-on : ubuntu-latest
1217
1318 steps :
2328 with :
2429 version : 8
2530
31+ - name : Setup pnpm cache
32+ uses : actions/cache@v4
33+ with :
34+ path : ~/.pnpm-store
35+ key : ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
36+ restore-keys : ${{ runner.os }}-pnpm-
37+
2638 - name : Install dependencies
2739 run : pnpm install
2840
3648
3749 build-and-release :
3850 needs : test
51+ permissions :
52+ contents : write
53+
3954 runs-on : ubuntu-latest
40- if : github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
55+ if : |
56+ (github.event_name == 'push' && !contains(github.event.head_commit.message, '[skip-release]')) ||
57+ (github.event_name == 'pull_request' && github.event.pull_request.merged == true && !contains(github.event.pull_request.title, '[skip-release]'))
4158
4259 steps :
4360 - uses : actions/checkout@v4
@@ -52,19 +69,32 @@ jobs:
5269 with :
5370 version : 8
5471
72+ - name : Setup pnpm cache
73+ uses : actions/cache@v4
74+ with :
75+ path : ~/.pnpm-store
76+ key : ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
77+ restore-keys : ${{ runner.os }}-pnpm-
78+
5579 - name : Install dependencies
5680 run : pnpm install
5781
5882 - name : Build extension
5983 run : pnpm run build
60-
84+
6185 - name : Create extension archive
6286 run : |
6387 node chromePackage.js
88+ if [ ! -f extension.zip ]; then
89+ echo "Failed to create extension.zip"
90+ exit 1
91+ fi
6492
6593 # Chrome Web Store deployment
6694 - name : Submit to Chrome Web Store
67- if : ${{ !contains(github.event.head_commit.message, '[skip-release]') && !contains(github.event.head_commit.message, '[skip-release-chrome]') }}
95+ if : |
96+ (github.event_name == 'push' && !contains(github.event.head_commit.message, '[skip-release]') && !contains(github.event.head_commit.message, '[skip-release-chrome]')) ||
97+ (github.event_name == 'pull_request' && github.event.pull_request.merged == true && !contains(github.event.pull_request.title, '[skip-release]') && !contains(github.event.pull_request.title, '[skip-release-chrome]'))
6898 run : |
6999 npx chrome-webstore-upload-cli@2 upload --source extension.zip --auto-publish
70100 env :
@@ -73,12 +103,13 @@ jobs:
73103 CLIENT_SECRET : ${{ secrets.CLIENT_SECRET }}
74104 REFRESH_TOKEN : ${{ secrets.REFRESH_TOKEN }}
75105
76- # Microsoft Edge Add-on deployment
106+ # Microsoft Edge Add-ons deployment
77107 - name : Submit to Microsoft Edge Add-ons
78- if : ${{ !contains(github.event.head_commit.message, '[skip-release]') && !contains(github.event.head_commit.message, '[skip-release-edge]') }}
108+ if : |
109+ (github.event_name == 'push' && !contains(github.event.head_commit.message, '[skip-release]') && !contains(github.event.head_commit.message, '[skip-release-edge]')) ||
110+ (github.event_name == 'pull_request' && github.event.pull_request.merged == true && !contains(github.event.pull_request.title, '[skip-release]') && !contains(github.event.pull_request.title, '[skip-release-edge]'))
79111 run : |
80112 echo "Uploading package to Edge Add-ons..."
81- # -i オプションでレスポンスヘッダーも取得しますが、出力時に秘密情報は隠します
82113 UPLOAD_RESPONSE=$(curl -s -i -w "\n%{http_code}" -X POST \
83114 -H "Authorization: ApiKey ${{ secrets.EDGE_API_KEY }}" \
84115 -H "X-ClientID: ${{ secrets.EDGE_CLIENT_ID }}" \
@@ -91,22 +122,17 @@ jobs:
91122
92123 if [ "$UPLOAD_HTTP_CODE" != "202" ]; then
93124 echo "Failed to upload package. HTTP Code: $UPLOAD_HTTP_CODE"
94- echo "Response omitted for security reasons."
95125 exit 1
96126 fi
97127
98- # Location ヘッダーから OPERATION_ID を抽出(改行コード除去)
99128 OPERATION_ID=$(echo "$UPLOAD_RESPONSE" | grep -i "Location:" | awk '{print $2}' | tr -d '\r')
100129
101130 if [ -z "$OPERATION_ID" ]; then
102131 echo "Failed to get operation ID from response"
103- echo "Response omitted for security reasons."
104132 exit 1
105133 fi
106134
107135 echo "Package uploaded. Operation ID: $OPERATION_ID"
108-
109- # アップロード完了まで待機
110136 echo "Waiting for upload to complete..."
111137 MAX_ATTEMPTS=30
112138 ATTEMPT=1
@@ -122,10 +148,8 @@ jobs:
122148 STATUS_HTTP_CODE=$(echo "$STATUS_RESPONSE" | tail -n1)
123149 STATUS_BODY=$(echo "$STATUS_RESPONSE" | sed '$d')
124150
125- # HTTP 200 または 202 を正常なレスポンスとして扱う
126151 if [ "$STATUS_HTTP_CODE" != "200" ] && [ "$STATUS_HTTP_CODE" != "202" ]; then
127152 echo "Failed to get status. HTTP Code: $STATUS_HTTP_CODE"
128- echo "Response omitted for security reasons."
129153 exit 1
130154 fi
131155
@@ -136,7 +160,6 @@ jobs:
136160 break
137161 elif [ "$STATUS" = "Failed" ]; then
138162 echo "Upload failed"
139- echo "Response omitted for security reasons."
140163 exit 1
141164 fi
142165
@@ -149,7 +172,6 @@ jobs:
149172 sleep 10
150173 done
151174
152- # サブミッションの公開
153175 echo "Publishing submission..."
154176 PUBLISH_RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
155177 -H "Authorization: ApiKey ${{ secrets.EDGE_API_KEY }}" \
@@ -159,11 +181,8 @@ jobs:
159181 https://api.addons.microsoftedge.microsoft.com/v1/products/${{ secrets.EDGE_PRODUCT_ID }}/submissions)
160182
161183 PUBLISH_HTTP_CODE=$(echo "$PUBLISH_RESPONSE" | tail -n1)
162- PUBLISH_BODY=$(echo "$PUBLISH_RESPONSE" | sed '$d')
163-
164184 if [ "$PUBLISH_HTTP_CODE" != "202" ]; then
165185 echo "Failed to publish submission. HTTP Code: $PUBLISH_HTTP_CODE"
166- echo "Response omitted for security reasons."
167186 exit 1
168187 fi
169188
0 commit comments