Skip to content

Commit c2099bf

Browse files
authored
ci: use GHA for CFA releases (#149)
1 parent 430361c commit c2099bf

File tree

7 files changed

+146
-128
lines changed

7 files changed

+146
-128
lines changed

.circleci/config.yml

Lines changed: 0 additions & 94 deletions
This file was deleted.

.github/workflows/publish-npm.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Publish npm Release
2+
3+
on:
4+
push:
5+
tags:
6+
- v[0-9]+.[0-9]+.[0-9]+
7+
8+
jobs:
9+
test:
10+
uses: ./.github/workflows/test.yml
11+
with:
12+
electron-version: ${{ github.ref_name }}
13+
release:
14+
runs-on: ubuntu-latest
15+
needs: test
16+
environment: npm
17+
permissions:
18+
contents: write # for creating new release
19+
id-token: write # for CFA
20+
steps:
21+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
22+
- name: "Use Node.js ${{ matrix.node-version }}"
23+
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
24+
with:
25+
node-version: "20.16.0"
26+
- name: Update Version
27+
run: node script/update-version.js ${{ github.ref_name }}
28+
- name: Confirm Version Updated
29+
run: node -e "if (require('./package.json').version === '0.0.0-development') process.exit(1)"
30+
- name: Install Dependencies
31+
run: npm ci
32+
- name: Obtain OIDC token
33+
id: oidc
34+
run: |
35+
token=$(curl --fail -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
36+
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=continuousauth.dev" | jq -r '.value')
37+
echo "::add-mask::${token}"
38+
echo "token=${token}" >> $GITHUB_OUTPUT
39+
- name: Obtain GitHub credentials
40+
id: github_creds
41+
run: |
42+
token=$(curl --fail "https://continuousauth.dev/api/request/${{ secrets.CFA_PROJECT_ID }}/github/credentials" \
43+
-X POST \
44+
-H "Content-Type: application/json" \
45+
-H "Authorization: bearer ${{ secrets.CFA_SECRET }}" \
46+
--data "{\"token\":\"${{ steps.oidc.outputs.token }}\"}" | jq -r '.GITHUB_TOKEN')
47+
echo "::add-mask::${token}"
48+
echo "token=${token}" >> $GITHUB_OUTPUT
49+
- name: Set NPM Credentials
50+
run: echo //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} > ~/.npmrc
51+
- name: Check NPM Credentials
52+
run: npm whoami
53+
- name: CFA Publish
54+
env:
55+
CFA_PROJECT_ID: ${{ secrets.CFA_PROJECT_ID }}
56+
CFA_SECRET: ${{ secrets.CFA_SECRET }}
57+
GITHUB_OIDC_TOKEN: ${{ steps.oidc.outputs.token }}
58+
run: node script/publish.js
59+
- name: Create Release
60+
env:
61+
GITHUB_TOKEN: ${{ steps.github_creds.outputs.token }}
62+
run: gh release create ${{ github.ref_name }} -t ${{ github.ref_name }}

.github/workflows/release.yml

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,26 @@ on:
77
description: Electron version to use with "v" prefix (e.g. v30.0.0)
88
required: true
99

10-
env:
11-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12-
1310
jobs:
14-
smoke_test:
11+
test:
12+
uses: ./.github/workflows/test.yml
13+
with:
14+
electron-version: ${{ github.event.inputs.version }}
15+
tag_new_version:
1516
runs-on: ubuntu-latest
17+
environment: deps-releaser
18+
needs: test
1619
steps:
17-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
18-
- name: Setup Node.js
19-
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
20+
- name: Generate GitHub App token
21+
uses: electron/github-app-auth-action@384fd19694fe7b6dcc9a684746c6976ad78228ae # v1.1.1
22+
id: generate-token
2023
with:
21-
node-version: "20.10.0"
22-
- name: Update Version
23-
run: node script/update-version.js ${{ github.event.inputs.version }}
24-
- name: Install Dependencies
25-
run: npm i
26-
- name: Run Tests
27-
run: npm test
28-
create_new_version:
29-
runs-on: ubuntu-latest
30-
needs: smoke_test
31-
permissions:
32-
contents: write
33-
steps:
34-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
35-
# Tag here, the CircleCI workflow will trigger on the new tag and do the CFA publish
24+
creds: ${{ secrets.DEPS_RELEASER_GH_APP_CREDS }}
25+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
26+
with:
27+
token: ${{ steps.generate-token.outputs.token }}
28+
# Tag here, the publish-npm.yml workflow will trigger on the new tag and do the CFA publish
3629
- name: Push New Tag
3730
run: |
3831
git tag ${{ github.event.inputs.version }}
3932
git push origin ${{ github.event.inputs.version }}
40-
- name: Create Release
41-
run: |
42-
gh release create ${{ github.event.inputs.version }} -t ${{ github.event.inputs.version }}

.github/workflows/test.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Test
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
electron-version:
7+
required: true
8+
type: string
9+
workflow_dispatch:
10+
schedule:
11+
- cron: '0 19 * * 1-5'
12+
push:
13+
branches:
14+
- main
15+
pull_request:
16+
branches:
17+
- main
18+
19+
permissions:
20+
contents: read
21+
22+
jobs:
23+
test:
24+
defaults:
25+
run:
26+
shell: bash
27+
strategy:
28+
matrix:
29+
node-version:
30+
- '20.16.0'
31+
- '18.20.4'
32+
- '16.20.2'
33+
- '14.21.3'
34+
os:
35+
- macos-latest
36+
- ubuntu-latest
37+
- windows-latest
38+
exclude:
39+
- os: macos-latest
40+
node-version: 14.21.3
41+
runs-on: "${{ matrix.os }}"
42+
steps:
43+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
44+
- name: "Use Node.js ${{ matrix.node-version }}"
45+
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
46+
with:
47+
node-version: "${{ matrix.node-version }}"
48+
- name: Update Version
49+
if: ${{ inputs.electron-version != '' }}
50+
run: node script/update-version.js ${{ inputs.electron-version }}
51+
- name: Use Latest Electron Version
52+
if: ${{ inputs.electron-version == '' }}
53+
run: echo "ELECTRON_CHROMEDRIVER_STABLE_FALLBACK=1" >> $GITHUB_ENV
54+
- name: Install Dependencies
55+
run: npm ci
56+
- name: Run Tests
57+
run: |
58+
node --version
59+
npm --version
60+
npm test

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Electron ChromeDriver
22

3-
[![CircleCI Status](https://circleci.com/gh/electron/chromedriver/tree/main.svg?style=shield)](https://circleci.com/gh/electron/chromedriver/tree/main)
3+
[![Test](https://github.com/electron/chromedriver/actions/workflows/test.yml/badge.svg)](https://github.com/electron/chromedriver/actions/workflows/test.yml)
44
[![npm:](https://img.shields.io/npm/v/electron-chromedriver.svg)](https://www.npmjs.com/package/electron-chromedriver)
55
<br>
66
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"extract-zip": "^2.0.0"
2626
},
2727
"devDependencies": {
28-
"@continuous-auth/client": "^2.2.2",
28+
"@continuous-auth/client": "^2.3.0",
2929
"@electron/fiddle-core": "^1.3.3",
3030
"mocha": "^10.1.0",
3131
"standard": "^13.1.0"

0 commit comments

Comments
 (0)