Skip to content

Commit 5406bc4

Browse files
committed
chore: setup semantic-release
1 parent 9869b3d commit 5406bc4

File tree

4 files changed

+44
-33
lines changed

4 files changed

+44
-33
lines changed

.github/workflows/release.yml

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,14 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v2
14-
- name: Prevent releasing if the repo is generated from the template and pkg.name not changed
15-
run: |
16-
set -e
17-
repo="$GITHUB_REPOSITORY"
18-
pkg=$(node -p 'require("./package.json").name')
19-
if [ "$pkg" == "@tlib/package-template" ] && [ "$repo" != 'tlibjs/package-template' ]; then
20-
echo 'Please modify "name" field in package.json' >&2
21-
exit 1
22-
else
23-
echo "Start releasing package $pkg in repo $repo"
24-
fi
2514
- name: Use Node.js
2615
uses: actions/setup-node@v2
2716
with:
28-
node-version: "14"
17+
node-version: "16"
2918
# https://github.com/actions/cache/blob/master/examples.md#node---yarn
3019
- name: Get yarn cache directory path
3120
id: yarn-cache-dir-path
32-
run: echo "::set-output name=dir::$(yarn cache dir)"
21+
run: echo "::set-output name=dir::$(./.yarn/cache)"
3322
- uses: actions/cache@v2
3423
id: yarn-cache
3524
with:
@@ -38,24 +27,22 @@ jobs:
3827
restore-keys: |
3928
${{ runner.os }}-yarn-
4029
- name: Install dependencies
41-
run: yarn install --frozen-lockfile
30+
run: yarn install --immutable
4231
- name: Ensure linted
4332
run: yarn run ensure-linted
44-
- name: Test
45-
run: yarn test
46-
- name: Build
47-
run: yarn build
33+
- name: Rust Build & Test
34+
run: cargo build --verbose && cargo test --verbose
4835
- name: Release
4936
env:
5037
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
38+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
5239
run: |
5340
if [ -z "$GITHUB_TOKEN" ]; then
5441
echo 'Unexpected empty GITHUB_TOKEN' >&2
5542
exit 1
5643
fi
57-
if [ -z "$NPM_TOKEN" ]; then
58-
echo 'Please set secrets.NPM_TOKEN' >&2
44+
if [ -z "$CARGO_REGISTRY_TOKEN" ]; then
45+
echo 'Please set secrets.CARGO_REGISTRY_TOKEN' >&2
5946
exit 1
6047
fi
6148
yarn run semantic-release

.lintstagedrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
"*.{js,ts}": "yarn run lint:fix"
1+
"!(.yarn)/**/*.{js,ts}": "yarn run lint:fix"
22
"*.{md,html,css,yml,yaml,json}": "prettier --write"

release.config.js

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
const CARGO_PROJECTS = [
2+
//
3+
"frender",
4+
];
5+
6+
const CARGO_FILES = CARGO_PROJECTS.map((dir) => `${dir}/Cargo.toml`);
7+
18
module.exports = {
29
branches: [
310
"+([0-9])?(.{+([0-9]),x}).x",
@@ -11,9 +18,34 @@ module.exports = {
1118
"@semantic-release/commit-analyzer",
1219
"@semantic-release/release-notes-generator",
1320
"@semantic-release/changelog",
14-
["@semantic-release/npm", { npmPublish: false }],
15-
["@semantic-release/npm", { pkgRoot: "dist" }],
16-
"@semantic-release/git",
21+
[
22+
"@google/semantic-release-replace-plugin",
23+
{
24+
replacements: [
25+
{
26+
files: CARGO_FILES,
27+
from: 'version = ".*" # replace version',
28+
to: 'version = "${nextRelease.version}" # replace version',
29+
results: CARGO_FILES.map((file) => ({
30+
file,
31+
hasChanged: true,
32+
numMatches: 1,
33+
numReplacements: 1,
34+
})),
35+
countMatches: true,
36+
},
37+
],
38+
},
39+
],
40+
["@semantic-release/exec", { prepareCmd: "cargo check" }],
41+
...CARGO_PROJECTS.map((pro) => [
42+
"@semantic-release/exec",
43+
{ publishCmd: "cargo publish", execCwd: pro },
44+
]),
45+
[
46+
"@semantic-release/git",
47+
{ assets: ["CHANGELOG.md", "Cargo.lock", ...CARGO_FILES] },
48+
],
1749
"@semantic-release/github",
1850
],
1951
};

rollup.config.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)