-
Notifications
You must be signed in to change notification settings - Fork 7
110 lines (105 loc) · 3.79 KB
/
Copy pathrelease.yml
File metadata and controls
110 lines (105 loc) · 3.79 KB
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
name: Release
# On a published GitHub release: build the per-platform binaries, publish the
# npm packages (launcher + 5 platform packages) and publish to PyPI. The tag
# name (e.g. v0.1.0) drives the version.
on:
release:
types: [published]
jobs:
binaries:
uses: ./.github/workflows/build-binaries.yml
npm:
needs: binaries
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
- name: Download built binaries
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Stage binaries into platform packages
run: |
node npm/stage.mjs linux-x64 artifacts/becwright-linux-x64/becwright
node npm/stage.mjs linux-arm64 artifacts/becwright-linux-arm64/becwright
# One universal2 macOS binary serves both Apple Silicon and Intel.
node npm/stage.mjs darwin-arm64 artifacts/becwright-darwin-universal2/becwright
node npm/stage.mjs darwin-x64 artifacts/becwright-darwin-universal2/becwright
node npm/stage.mjs win32-x64 artifacts/becwright-win32-x64/becwright.exe
- name: Set version from tag
run: node npm/set-version.mjs "${GITHUB_REF_NAME#v}"
# Use leading "./" so npm treats the argument as a folder, not a GitHub
# "owner/repo" shorthand. Skip versions already on the registry so a re-run
# after a partial failure is safe (npm publish is not idempotent).
- name: Publish platform packages
run: |
for dir in npm/platforms/*/; do
name=$(node -p "require('./${dir}package.json').name")
ver=$(node -p "require('./${dir}package.json').version")
if npm view "$name@$ver" version >/dev/null 2>&1; then
echo "skip $name@$ver (already published)"
else
npm publish "./$dir" --access public
fi
done
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish launcher package
run: |
ver=$(node -p "require('./npm/becwright/package.json').version")
if npm view "becwright@$ver" version >/dev/null 2>&1; then
echo "skip becwright@$ver (already published)"
else
npm publish ./npm/becwright --access public
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
pypi:
runs-on: ubuntu-latest
permissions:
id-token: write # PyPI Trusted Publishing (OIDC)
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build
run: |
pip install build
python -m build
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
docker:
needs: pypi
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=raw,value=latest,enable=${{ !github.event.release.prerelease }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}