forked from ampproject/amphtml
-
Notifications
You must be signed in to change notification settings - Fork 1
69 lines (69 loc) · 3.06 KB
/
publish-npm-packages.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
name: Publish Bento Packages on npm
on:
workflow_dispatch:
inputs:
ampversion:
description: 'AMP version'
required: true
tag:
description: 'npm package tag (latest | nightly)'
required: true
jobs:
setup:
runs-on: ubuntu-latest
outputs:
extensions: ${{ steps.get-extensions.outputs.extensions }}
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.events.inputs.ampversion }}
- name: Get latest scripts
run: wget -q "https://raw.githubusercontent.com/ampproject/amphtml/main/build-system/npm-publish/get-extensions.js" -O ./build-system/npm-publish/get-extensions.js
- name: Get extensions to publish
id: get-extensions
run: |
EXTENSIONS=$(node ./build-system/npm-publish/get-extensions.js)
echo "::set-output name=extensions::{\"include\":${EXTENSIONS}}"
publish:
if: github.repository == 'ampproject/amphtml'
environment: bento_publishing
needs: setup
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.setup.outputs.extensions) }}
fail-fast: false
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.events.inputs.ampversion }}
- uses: actions/setup-node@v2
with:
check-latest: true
registry-url: https://registry.npmjs.org
- name: Get latest scripts
run: |
wget -q "https://raw.githubusercontent.com/ampproject/amphtml/main/build-system/npm-publish/build-npm-binaries.js" -O ./build-system/npm-publish/build-npm-binaries.js
wget -q "https://raw.githubusercontent.com/ampproject/amphtml/main/build-system/npm-publish/write-package-files.js" -O ./build-system/npm-publish/write-package-files.js
- name: Build package
run: |
npm install
node ./build-system/npm-publish/build-npm-binaries.js ${{ matrix.extension }}
node ./build-system/npm-publish/write-package-files.js ${{ matrix.extension }} ${{ github.event.inputs.ampversion }} ${{ matrix.version }}
- name: Publish package for Nightly releases
if: github.event.inputs.tag != 'latest'
run: npm publish ./extensions/${{ matrix.extension }}/${{ matrix.version }} --access public --tag ${{ github.event.inputs.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Tag package as latest for Stable releases
if: github.event.inputs.tag == 'latest'
run: |
NPM_PACKAGE=$(jq -r .name ./extensions/${{ matrix.extension }}/${{ matrix.version }}/package.json)
NPM_VERSION=$(jq -r .version ./extensions/${{ matrix.extension }}/${{ matrix.version }}/package.json)
echo "Processing ${NPM_PACKAGE}@${NPM_VERSION}"
if [[ $(npm view ${NPM_PACKAGE}@${NPM_VERSION}) ]]; then
npm dist-tag add ${NPM_PACKAGE}@${NPM_VERSION} latest
else
npm publish ./extensions/${{ matrix.extension }}/${{ matrix.version }} --access public --tag latest
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}