forked from web-platform-dx/web-features
-
Notifications
You must be signed in to change notification settings - Fork 2
87 lines (79 loc) · 2.77 KB
/
publish_next_web-features.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
name: Publish web-features@next
on:
push:
branches:
- "main"
paths:
- features/**
- groups/**
- packages/web-features/**
- snapshots/**
- index.ts
- scripts/build.ts
permissions:
contents: write
env:
package: "web-features"
package_dir: "packages/web-features"
dist_tag: "next"
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
- run: npm ci
- run: npm test
publish:
if: github.repository == 'web-platform-dx/web-features'
runs-on: ubuntu-latest
needs: "test"
steps:
- uses: actions/checkout@v4
- name: Get timestamp and short hash
id: timestamp_and_hash
run: |
echo "TIMESTAMP=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
echo "SHORT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
registry-url: "https://registry.npmjs.org"
- run: npm ci
- run: npm run build
- run: npm run build:extended
- name: Get package.json version
id: version
run: echo "VERSION=$(npm version --json | jq --raw-output '.["${{ env.package }}"]')" >> $GITHUB_OUTPUT
working-directory: ${{ env.package_dir }}
- run: npm install
working-directory: ${{ env.package_dir }}
- run: npm version --no-git-tag-version "$VERSION-dev-$TIMESTAMP-$SHORT_HASH"
# The version string template is: <package.json version>-dev-<timestamp>-<commit-hash>
# Why not use SemVer build metadata with a plus sign for some of this?
# Because npm completely ignores it. 😒
working-directory: ${{ env.package_dir }}
env:
VERSION: ${{ steps.version.outputs.VERSION }}
TIMESTAMP: ${{ steps.timestamp_and_hash.outputs.TIMESTAMP }}
SHORT_HASH: ${{ steps.timestamp_and_hash.outputs.SHORT_HASH }}
- run: npm publish --tag ${{ env.dist_tag }}
working-directory: ${{ env.package_dir }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish pre-release on GitHub
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 #v2.0.8
with:
files: |
schemas/data.schema.json
${{ env.package_dir }}/data.json
data.extended.json
prerelease: true
name: web-features@next
body: This is a continuously-updated prerelease generated from `main` (currently at ${{ steps.timestamp_and_hash.outputs.SHORT_HASH }}).
tag_name: ${{ env.dist_tag }}
fail_on_unmatched_files: true