Skip to content

Commit a031fb2

Browse files
committed
Deno 2.0 and jsr.io compatibility. (#52)
1 parent 6b238b1 commit a031fb2

File tree

101 files changed

+1395
-746
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+1395
-746
lines changed

.github/workflows/build.yml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,30 @@ on:
1515
jobs:
1616
build:
1717
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
id-token: write # The OIDC ID token is used for authentication with JSR.
1821
steps:
19-
- uses: actions/checkout@v1
20-
- uses: actions/setup-node@v1
22+
- uses: actions/checkout@v4
23+
- uses: denoland/setup-deno@v2
2124
with:
22-
node-version: 16
23-
registry-url: https://registry.npmjs.org/
24-
- uses: denoland/setup-deno@v1
25-
with:
26-
deno-version: v1.40
25+
deno-version: v2.x
2726
- name: Run tests
2827
run: deno test test/**/*.test.ts
2928

30-
- uses: actions/setup-go@v3
29+
- uses: actions/setup-go@v5
3130
with:
32-
go-version: "1.21"
33-
34-
- name: Bundle module and dependencies
35-
run: deno bundle src/mod.ts bundle.js
31+
go-version: "1.24"
3632

3733
- name: Install Apex CLI
38-
run: deno install -A -f -n apex https://deno.land/x/[email protected]/apex.ts
34+
run: deno install -g -A --unstable-worker-options -f -n apex jsr:@apexlang/apex
3935

4036
- name: Install Protoc
4137
run: |
4238
PB_REL="https://github.com/protocolbuffers/protobuf/releases"
4339
curl -LO $PB_REL/download/v3.15.8/protoc-3.15.8-linux-x86_64.zip
4440
sudo unzip protoc-3.15.8-linux-x86_64.zip -d /usr/local
41+
sudo rm protoc-3.15.8-linux-x86_64.zip
4542
4643
- name: Install protoc-gen-go
4744
run: |
@@ -59,3 +56,11 @@ jobs:
5956
- name: Validate generated OpenAPI
6057
run: find . -name 'openapi.yaml' -exec swagger-cli validate {} \;
6158
working-directory: ./testdata
59+
60+
- name: Is Release?
61+
if: startswith(github.ref, 'refs/tags/v')
62+
run: echo "DEPLOY_PACKAGE=true" >> $GITHUB_ENV
63+
64+
- name: Publish to npm
65+
if: env.DEPLOY_PACKAGE == 'true'
66+
run: npx jsr publish

.github/workflows/release.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
function env(name: string): string {
2+
const val = Deno.env.get(name);
3+
if (!val) throw new Error(`$${name} is required`);
4+
return val;
5+
}
6+
7+
const version = env("VERSION");
8+
9+
if (!version.match(/^v\d+\.\d+\.\d+$/)) {
10+
throw new Error("VERSION must be in the form v1.2.3");
11+
}
12+
13+
console.log("Updating versions in files");
14+
15+
for (const file of ["jsr.json", "deno.json"]) {
16+
console.log(`Updating ${file} for ${version}...`);
17+
const orig = Deno.readTextFileSync(file);
18+
const updated = orig.replace(/\d+\.\d+\.\d+/, version.substring(1));
19+
Deno.writeFileSync(file, new TextEncoder().encode(updated));
20+
}

.github/workflows/release.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Release apex version
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Version to release"
8+
required: true
9+
10+
jobs:
11+
release:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
token: ${{ secrets.RELEASE_TOKEN }}
19+
- uses: denoland/setup-deno@v2
20+
with:
21+
deno-version: v2.x
22+
- name: Update version and README.md
23+
env:
24+
VERSION: ${{ inputs.version }}
25+
run: |
26+
deno run --allow-run --allow-env --allow-write --allow-read ./.github/workflows/release.ts
27+
- name: Commit and tag release
28+
uses: stefanzweifel/git-auto-commit-action@v4
29+
with:
30+
commit_message: ${{ inputs.version }} release
31+
tagging_message: ${{ inputs.version }}
32+
- name: Create Release
33+
uses: ncipollo/[email protected]
34+
with:
35+
generateReleaseNotes: true
36+
makeLatest: true
37+
tag: ${{ inputs.version }}

deno.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "@apexlang/codegen",
3+
"version": "0.1.10",
4+
"description": "Code generators for Apex.",
5+
"keywords": ["apex", "idl", "codegen"],
6+
"license": "Apache-2.0",
7+
"repository": {
8+
"type": "git",
9+
"url": "https://www.github.com/apexlang/codegen"
10+
},
11+
"bugs": {
12+
"url": "https://www.github.com/apexlang/codegen/issues"
13+
},
14+
"imports": {
15+
"@apexlang/apex": "jsr:@apexlang/apex@^0.2.0",
16+
"@apexlang/core": "jsr:@apexlang/core@^0.2.0",
17+
"@std/assert": "jsr:@std/assert@^1.0.11",
18+
"@std/yaml": "jsr:@std/yaml@^1.0.5"
19+
},
20+
"exports": {
21+
"./cs": "./src/cs/mod.ts",
22+
"./go": "./src/go/mod.ts",
23+
"./json-schema": "./src/json-schema/mod.ts",
24+
"./markdown": "./src/markdown/mod.ts",
25+
"./openapiv3": "./src/openapiv3/mod.ts",
26+
"./proto": "./src/proto/mod.ts",
27+
"./python": "./src/python/mod.ts",
28+
"./rest": "./src/rest/mod.ts",
29+
"./rust": "./src/rust/mod.ts",
30+
"./typescript": "./src/typescript/mod.ts",
31+
"./utils": "./src/utils/mod.ts"
32+
},
33+
"publish": {
34+
"include": ["LICENSE", "README.md", "templates", "src/**/*.ts"],
35+
"exclude": ["src/tests"]
36+
}
37+
}

deno.lock

Lines changed: 242 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)