Skip to content

Commit

Permalink
Merge pull request #1 from TomokiMiyauci/beta
Browse files Browse the repository at this point in the history
Beta
  • Loading branch information
TomokiMiyauci committed Jun 14, 2023
2 parents 3dd4590 + 0f214bd commit ad5758c
Show file tree
Hide file tree
Showing 22 changed files with 680 additions and 2 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/codeql-analysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "CodeQL"

on:
push:
branches: [ main ]

pull_request:
branches: [ main ]

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'typescript' ]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
57 changes: 57 additions & 0 deletions .github/workflows/release-npm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: release-npm

on:
release:
types: [published]

jobs:
release:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
deno: [v1.x]
node: [18.x]

steps:
- name: Checkout
uses: actions/checkout@v3

- uses: denoland/setup-deno@v1
with:
deno-version: ${{ matrix.deno }}

- name: Cache node_modules
uses: actions/cache@v2
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-
- uses: pnpm/action-setup@v2.0.1
with:
version: 6.23.6
run_install: |
- recursive: true
args: [--frozen-lockfile, --prefer-offline, --ignore-scripts]
- name: Get tag version
if: startsWith(github.ref, 'refs/tags/')
id: get_tag_version
run: echo ::set-output name=TAG_VERSION::${GITHUB_REF/refs\/tags\//}

- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
registry-url: 'https://registry.npmjs.org'

- name: build
run: deno run -A ./_tools/build_npm.ts ${{steps.get_tag_version.outputs.TAG_VERSION}}

- name: publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: deno run -A ./_tools/publish_npm.ts ${{steps.get_tag_version.outputs.TAG_VERSION}}

79 changes: 79 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: release

on:
push:
branches:
- beta
- main

jobs:
lint:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
deno: [v1.x]

steps:
- name: Checkout
uses: actions/checkout@v3

- uses: denoland/setup-deno@v1
with:
deno-version: ${{ matrix.deno }}

- name: Lint
run: |
deno fmt --check
deno lint
test:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
deno: [v1.x]

steps:
- name: Checkout
uses: actions/checkout@v3

- uses: denoland/setup-deno@v1
with:
deno-version: ${{ matrix.deno }}

- name: Test
run: deno task test --coverage=coverage

- name: Generate coverage
if: ${{ matrix.deno == 'v1.x' }}
run: deno coverage coverage --output=cov_profile.lcov --lcov

- uses: codecov/codecov-action@v3
if: ${{ matrix.deno == 'v1.x' }}
with:
files: cov_profile.lcov

release:
needs: [lint, test]
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]

steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GH_TOKEN }}

- uses: cycjimmy/semantic-release-action@v3
with:
extra_plugins: |
@semantic-release/changelog
@semantic-release/git
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
43 changes: 43 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: test

on: push
jobs:
lint:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
deno: [v1.x]

steps:
- name: Checkout
uses: actions/checkout@v3

- uses: denoland/setup-deno@v1
with:
deno-version: ${{ matrix.deno }}

- name: Lint
run: |
deno fmt --check
deno lint
test:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
deno: [v1.x]

steps:
- name: Checkout
uses: actions/checkout@v3

- uses: denoland/setup-deno@v1
with:
deno-version: ${{ matrix.deno }}

- name: Test
run: deno task test
25 changes: 25 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"branches": [
"main",
{
"name": "beta",
"prerelease": true
}
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"@semantic-release/github",
[
"@semantic-release/git",
{
"assets": [
"CHANGELOG.md"
],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
]
],
"tagFormat": "${version}"
}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# 1.0.0-beta.1 (2023-06-14)


### Features

* **composite:** add composite key and composite symbol impl ([ee3dcf7](https://github.com/TomokiMiyauci/composite-key/commit/ee3dcf7f615c7ccf1398274f6abb9bacd69b8ddb))
* **mod:** export all API ([744707c](https://github.com/TomokiMiyauci/composite-key/commit/744707c3f4955ac508be8ab5a34230cb09b9716c))
* **polyfill:** add polyfill for composite key and composite symbol ([e1525cd](https://github.com/TomokiMiyauci/composite-key/commit/e1525cd84b4f578ce2291eb679d6647808ef2eea))
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ The entrypoint of each are as follows:

## compositeKey

`compositeKey` requires at least one component must be object that can be placed
in a `WeakMap`.
Return reference consisting of a component. This allows using a `Map`, `Set` and
`WeakMap` to weakly and/or privately associate data with the lifetime of a group
of values.

It requires at least one component must be object that can be placed in a
`WeakMap`.

```ts
import { compositeKey } from "https://deno.land/x/composite_key@$VERSION/mod.ts";
Expand Down
8 changes: 8 additions & 0 deletions _dev_deps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright 2023-latest Tomoki Miyauchi. All rights reserved. MIT license.

export {
assert,
assertEquals,
assertFalse,
} from "https://deno.land/std@0.190.0/testing/asserts.ts";
export { describe, it } from "https://deno.land/std@0.190.0/testing/bdd.ts";
6 changes: 6 additions & 0 deletions _test_import_map.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"imports": {
"https://deno.land/x/composite_key@$VERSION/": "./",
"https://deno.land/std/": "https://deno.land/std@0.190.0/"
}
}
23 changes: 23 additions & 0 deletions _tools/build_npm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { build, emptyDir } from "https://deno.land/x/dnt@0.37.0/mod.ts";
import { join } from "https://deno.land/std@0.177.0/path/mod.ts";
import { makeOptions } from "./meta.ts";

async function buildPkg(version: string): Promise<void> {
await emptyDir("./npm");
const pkg = makeOptions(version);
await Deno.copyFile("LICENSE", join(pkg.outDir, "LICENSE"));
Deno.copyFile(
join(".", "README.md"),
join(pkg.outDir, "README.md"),
);
await build(pkg);
}

if (import.meta.main) {
const version = Deno.args[0];
if (!version) {
console.error("argument is required");
Deno.exit(1);
}
await buildPkg(version);
}
46 changes: 46 additions & 0 deletions _tools/meta.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { BuildOptions } from "https://deno.land/x/dnt@0.37.0/mod.ts";

export const makeOptions = (version: string): BuildOptions => ({
test: false,
shims: {},
typeCheck: "both",
entryPoints: ["./mod.ts", "./polyfill.ts"],
outDir: "./npm",
package: {
name: "composite-key",
version,
description:
"Composite keys, TC39 proposal-richer-keys of compositeKey implementation",
keywords: [
"composite",
"composite-key",
"gc",
"weak-map",
"tc39",
"proposal-richer-keys",
],
license: "MIT",
homepage: "https://github.com/TomokiMiyauci/composite-key",
repository: {
type: "git",
url: "git+https://github.com/TomokiMiyauci/composite-key.git",
},
bugs: {
url: "https://github.com/TomokiMiyauci/composite-key/issues",
},
sideEffects: false,
type: "module",
},
packageManager: "pnpm",
mappings: {
"https://deno.land/x/upsert@1.1.0/mod.ts": {
name: "@miyauci/upsert",
version: "1.1.0",
},
"https://deno.land/x/isx@1.4.0/is_string.ts": {
name: "@miyauci/isx",
version: "1.4.0",
subPath: "is_string.js",
},
},
});
27 changes: 27 additions & 0 deletions _tools/publish_npm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { prerelease, valid } from "https://deno.land/x/semver@v1.4.0/mod.ts";
import { makeOptions } from "./meta.ts";

if (import.meta.main) {
const version = Deno.args[0];
if (!version) {
console.error("arg of version is required");
Deno.exit(1);
}
if (!valid(version)) {
console.error("The argument of version is invalid");
Deno.exit(1);
}

const isPrerelease = prerelease(version);
const tag = isPrerelease?.[0] ?? "latest";

const pkg = makeOptions(version);
const command = new Deno.Command("npm", {
args: ["publish", pkg.outDir, "--tag", String(tag)],
});
const result = await command.output();

if (!result.success) {
console.error(new TextDecoder().decode(result.stderr));
}
}

0 comments on commit ad5758c

Please sign in to comment.