Skip to content

Commit d90343d

Browse files
authored
Create a continuous prerelease for GitHub (#1875)
This is like the `web-features@next` release on npm, but on GitHub and extended to the bare JSON artifacts. This is setup for #1860.
1 parent 18f2c54 commit d90343d

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

.github/workflows/publish_next_web-features.yml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ on:
1212
- index.ts
1313
- scripts/build.ts
1414

15+
permissions:
16+
contents: write
17+
1518
env:
1619
package: "web-features"
1720
package_dir: "packages/web-features"
@@ -33,32 +36,52 @@ jobs:
3336
runs-on: ubuntu-latest
3437
needs: "test"
3538
steps:
36-
- name: Get timestamp
37-
id: timestamp
38-
run: echo "TIMESTAMP=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
3939
- uses: actions/checkout@v4
40+
- name: Get timestamp and short hash
41+
id: timestamp_and_hash
42+
run: |
43+
echo "TIMESTAMP=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
44+
echo "SHORT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
45+
4046
- uses: actions/setup-node@v4
4147
with:
4248
node-version-file: .node-version
4349
cache: npm
4450
registry-url: "https://registry.npmjs.org"
4551
- run: npm ci
52+
4653
- run: npm run build
54+
- run: npm run build:extended
55+
4756
- name: Get package.json version
4857
id: version
4958
run: echo "VERSION=$(npm version --json | jq --raw-output '.["${{ env.package }}"]')" >> $GITHUB_OUTPUT
5059
working-directory: ${{ env.package_dir }}
5160
- run: npm install
5261
working-directory: ${{ env.package_dir }}
53-
- run: npm version --no-git-tag-version "$VERSION-dev-$TIMESTAMP-$(git rev-parse --short HEAD)"
62+
- run: npm version --no-git-tag-version "$VERSION-dev-$TIMESTAMP-$SHORT_HASH"
5463
# The version string template is: <package.json version>-dev-<timestamp>-<commit-hash>
5564
# Why not use SemVer build metadata with a plus sign for some of this?
5665
# Because npm completely ignores it. 😒
5766
working-directory: ${{ env.package_dir }}
5867
env:
5968
VERSION: ${{ steps.version.outputs.VERSION }}
60-
TIMESTAMP: ${{ steps.timestamp.outputs.TIMESTAMP }}
69+
TIMESTAMP: ${{ steps.timestamp_and_hash.outputs.TIMESTAMP }}
70+
SHORT_HASH: ${{ steps.timestamp_and_hash.outputs.SHORT_HASH }}
6171
- run: npm publish --tag ${{ env.dist_tag }}
6272
working-directory: ${{ env.package_dir }}
6373
env:
6474
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
75+
76+
- name: Publish pre-release on GitHub
77+
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 #v2.0.8
78+
with:
79+
files: |
80+
schemas/data.schema.json
81+
${{ env.package_dir }}/data.json
82+
data.extended.json
83+
prerelease: true
84+
name: web-features@next
85+
body: This is a continuously-updated prerelease generated from `main` (currently at ${{ steps.timestamp_and_hash.outputs.SHORT_HASH }}).
86+
tag_name: ${{ env.dist_tag }}
87+
fail_on_unmatched_files: true

0 commit comments

Comments
 (0)