Skip to content

Commit 5bff136

Browse files
committed
Update deploy flow to be triggered by a change in version.ts
1 parent aebb49e commit 5bff136

5 files changed

Lines changed: 24 additions & 25 deletions

File tree

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ jobs:
3030
with:
3131
node-version: '18.x'
3232
registry-url: 'https://registry.npmjs.org'
33-
33+
3434
- name: Test building of npm files
35-
run: deno task npm 0.0.0
35+
run: deno task npm

.github/workflows/release.yml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ name: Release
22

33
on:
44
push:
5-
tags:
6-
- '*'
5+
branches:
6+
- master
7+
paths:
8+
- 'version.ts'
79

810
jobs:
911
release:
@@ -27,23 +29,24 @@ jobs:
2729
env:
2830
SERPAPI_TEST_KEY: ${{ secrets.SERPAPI_TEST_KEY }}
2931
run: deno task test:ci
30-
31-
- name: Get tag version
32-
if: startsWith(github.ref, 'refs/tags/')
33-
id: get_tag_version
34-
run: echo "TAG_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
35-
32+
3633
- name: Setup Node
3734
uses: actions/setup-node@v3
3835
with:
3936
node-version: '18.x'
4037
registry-url: 'https://registry.npmjs.org'
41-
38+
4239
- name: Build npm files
43-
run: deno task npm ${{ steps.get_tag_version.outputs.TAG_VERSION }}
44-
40+
run: deno task npm
41+
42+
- name: Push tag
43+
run: |
44+
VERSION=$(cat version.ts | sed -n 's/.*"\(.*\)".*/\1/p')
45+
echo $VERSION
46+
git tag $VERSION
47+
git push origin $VERSION
48+
4549
- name: npm publish
46-
if: startsWith(github.ref, 'refs/tags/')
4750
env:
4851
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4952
run: cd npm && npm publish

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ and this project adheres to
1414

1515
### Changed
1616

17+
- Update deploy flow to be triggered by a change in `version.ts`.
18+
1719
### Fixed
1820

1921
### Removed

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ SerpApi project members will then review the request.
9696

9797
## Release new versions
9898

99-
1. Update changelog
99+
1. Update changelog.
100100
2. Merge the associated PR and ensure the "Build" workflow succeeds.
101-
3. Push a new tag based on [semantic versioning](https://semver.org/), e.g.
101+
3. Update `version.ts` based on [semantic versioning](https://semver.org/), e.g.
102102
`1.2.0`.
103-
4. Once the "Release" workflow succeeds, verify the new versions on npm and
104-
deno.land/x.
103+
4. Push `version.ts`. This triggers the "Release" workflow.
104+
5. Verify that new versions have been released on npm and deno.land/x.
105105

106106
[^1]: https://deno.land/manual/references/vscode_deno

scripts/build_npm.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
import { build, emptyDir } from "https://deno.land/x/dnt@0.32.0/mod.ts";
2+
import { version } from "../version.ts";
23

34
await emptyDir("./npm");
45

5-
const version = Deno.args[0];
6-
if (!version) {
7-
throw new Error(
8-
"Specify a version as the first argument, e.g. `deno task npm 0.0.1`",
9-
);
10-
}
11-
126
await build({
137
entryPoints: ["./mod.ts"],
148
outDir: "./npm",

0 commit comments

Comments
 (0)