Skip to content

Commit 2535ba6

Browse files
committed
ci: add manual alpha release dry run
1 parent c91421c commit 2535ba6

2 files changed

Lines changed: 68 additions & 52 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -48,58 +48,6 @@ jobs:
4848
with:
4949
path: ./dist
5050

51-
- name: get-npm-version
52-
id: package-version
53-
uses: martinbeentjes/npm-get-version-action@v1.3.1
54-
55-
- name: Get short commit hash
56-
id: vars
57-
run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
58-
59-
- name: Update package version to -<commit-hash>
60-
env:
61-
PACKAGE_VERSION: ${{ steps.package-version.outputs.current-version }}-alpha-${{ env.COMMIT_HASH }}
62-
run: |
63-
node <<'NODE'
64-
const fs = require("node:fs");
65-
const packageJsonPath = "package.json";
66-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
67-
packageJson.version = process.env.PACKAGE_VERSION;
68-
fs.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`);
69-
NODE
70-
71-
- name: Package npm package
72-
run: npm pack
73-
74-
- name: Upload npm package artifact
75-
uses: actions/upload-artifact@v7
76-
with:
77-
name: npm-package
78-
path: "*.tgz"
79-
80-
release:
81-
needs: build
82-
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
83-
runs-on: ubuntu-latest
84-
permissions:
85-
contents: read
86-
id-token: write
87-
steps:
88-
- name: Setup Node.js
89-
uses: actions/setup-node@v7
90-
with:
91-
node-version: "24"
92-
registry-url: https://registry.npmjs.org
93-
package-manager-cache: false
94-
95-
- name: Download npm package artifact
96-
uses: actions/download-artifact@v8
97-
with:
98-
name: npm-package
99-
100-
- name: Publish npm package
101-
run: npm publish ./rescript-webapi-*.tgz --access public --tag alpha
102-
10351
deploy-docs:
10452
needs: build
10553
runs-on: ubuntu-latest

‎.github/workflows/release.yml‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Release
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
inputs:
9+
dry_run:
10+
description: Run npm publish without publishing the package
11+
required: true
12+
default: true
13+
type: boolean
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
publish:
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
id-token: write
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v7
28+
29+
- name: Setup Node.js
30+
uses: actions/setup-node@v7
31+
with:
32+
node-version: "24"
33+
registry-url: https://registry.npmjs.org
34+
package-manager-cache: false
35+
36+
- name: Install dependencies
37+
run: npm ci
38+
39+
- name: get-npm-version
40+
id: package-version
41+
uses: martinbeentjes/npm-get-version-action@v1.3.1
42+
43+
- name: Get short commit hash
44+
id: vars
45+
run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
46+
47+
- name: Update package version to -<commit-hash>
48+
env:
49+
PACKAGE_VERSION: ${{ steps.package-version.outputs.current-version }}-alpha-${{ env.COMMIT_HASH }}
50+
run: |
51+
node <<'NODE'
52+
const fs = require("node:fs");
53+
const packageJsonPath = "package.json";
54+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
55+
packageJson.version = process.env.PACKAGE_VERSION;
56+
fs.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`);
57+
NODE
58+
59+
- name: Package npm package
60+
run: npm pack
61+
62+
- name: Dry-run npm publish
63+
if: github.event_name == 'pull_request' || inputs.dry_run
64+
run: npm publish ./rescript-webapi-*.tgz --access public --tag alpha --dry-run
65+
66+
- name: Publish npm package
67+
if: github.event_name == 'workflow_dispatch' && !inputs.dry_run
68+
run: npm publish ./rescript-webapi-*.tgz --access public --tag alpha

0 commit comments

Comments
 (0)