Skip to content

Commit

Permalink
build: Test release
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanmenzel committed Sep 27, 2024
1 parent 925abf4 commit a58e5b1
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 25 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ci-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ jobs:
node-version: 20.x
run-build: true
run-commit-lint: true
pre-test-script: |
pipx install algokit
algokit localnet start
build-script: npm run build
audit-script: npm run audit
upload-artifact-name: puya-ts
Expand Down
22 changes: 17 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,24 @@ jobs:
with:
path: artifacts

- name: Prepare @algorandfoundation/algo-ts
run: cp .releaserc.json artifacts/algo-ts/.releaserc.json

- name: Publish @algorandfoundation/algo-ts
uses: JS-DevTools/npm-publish@v3
id: publish_algo_ts
with:
token: ${{ secrets.NPM_SECRET }}
package: artifacts/algo-ts/package.json
access: 'public'
dry-run: true

- run: echo "type ${{ steps.publish_algo_ts.type }} name ${{ steps.publish_algo_ts.name }} version ${{ steps.publish_algo_ts.version }}"

# - name: Update puya-ts' peer dependency on algo-ts
# run: npx tsx ../../scripts/update-algo-ts-peer-dep.ts ${{ steps.publish_algo_ts.version }}
# working-directory: artifacts/puya-ts

- name: Publish @algorandfoundation/puya-ts
run: npx semantic-release
working-directory: artifacts/algo-ts/

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_SECRET }}
4 changes: 2 additions & 2 deletions .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
[
"@semantic-release/npm",
{
"npmPublish": true,
"pkgRoot": "."
"npmPublish": false,
"pkgRoot": "artifacts/puya-ts"
}
],
"@semantic-release/github"
Expand Down
13 changes: 9 additions & 4 deletions .tstoolkitrc.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import type { TsToolkitConfig } from "@makerx/ts-toolkit";
import type { TsToolkitConfig } from '@makerx/ts-toolkit'

const config: TsToolkitConfig = {
packageConfig: {
srcDir: 'src',
exportTypes: 'module',
outDir: 'dist',
moduleType: 'module',
exports: {
'.': 'index.ts',
'./cli': 'cli.ts',
'./internal': 'internal.ts'
}
}
'./internal': 'internal.ts',
},
bin: {
'puya-ts': 'bin/run-cli.ts',
puyats: 'bin/run-cli.ts',
},
},
}
export default config
13 changes: 8 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"build:3-build": "rollup -c --configPlugin typescript",
"build:4-copy-pkg-json": "tstk copy-package-json -c",
"build:5-copy-readme": "copyfiles ./README.md ./dist",
"test": "vitest run --exclude 'packages/**'",
"test": "vitest run",
"test:approvals": "vitest run tests/approvals/_run.spec.ts",
"test:expected-output": "vitest run tests/expected-output/_run.spec.ts",
"test:coverage": "vitest run --coverage",
Expand All @@ -51,7 +51,7 @@
"@commitlint/config-conventional": "^19.5.0",
"@makerx/eslint-config": "4.0.0",
"@makerx/prettier-config": "2.0.1",
"@makerx/ts-toolkit": "^4.0.0-beta.20",
"@makerx/ts-toolkit": "^4.0.0-beta.21",
"@rollup/plugin-commonjs": "28.0.0",
"@rollup/plugin-json": "6.1.0",
"@rollup/plugin-node-resolve": "15.3.0",
Expand Down Expand Up @@ -83,5 +83,8 @@
"glob": "^11.0.0",
"polytype": "^0.17.0",
"zod": "^3.23.8"
},
"peerDependencies": {
"@algorandfoundation/algo-ts": "0.0.1-alpha.1"
}
}
2 changes: 1 addition & 1 deletion packages/algo-ts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@algorandfoundation/algo-ts",
"version": "1.0.0",
"version": "0.0.1-alpha.1",
"description": "",
"main": "index.js",
"types": "src/index.ts",
Expand Down
3 changes: 2 additions & 1 deletion rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const config: RollupOptions = {
index: 'src/index.ts',
cli: 'src/cli.ts',
internal: 'src/internal.ts',
'bin/run-cli': 'src/bin/run-cli.ts',
},
output: [
{
Expand All @@ -21,7 +22,7 @@ const config: RollupOptions = {
},
],
treeshake: {
moduleSideEffects: false,
moduleSideEffects: true,
propertyReadSideEffects: false,
},
external: [/node_modules/, /tslib/],
Expand Down
30 changes: 30 additions & 0 deletions scripts/update-algo-ts-peer-dep.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* eslint-disable no-console */
import fs from 'fs'

const AlgoTsPackageName = '@algorandfoundation/algo-ts'
const newVersion = process.argv[2]

const SemVersionReg = /^\d+\.\d+\.\d+(-((beta)|(alpha))(\.\d+)?)?$/

if (!SemVersionReg.test(newVersion)) {
console.error(`Arg 2 of '${newVersion}' should be an npm compatible semantic version number`)
process.exit(1)
}

if (!fs.existsSync('package.json')) {
console.error('No package.json file could be found in the current working directory')
process.exit(2)
}

console.info('Loading package.json file')
const pkgJsonText = fs.readFileSync('package.json', 'utf-8')
const pkgJsonObj = JSON.parse(pkgJsonText)

if (!pkgJsonObj['peerDependencies']) {
pkgJsonObj['peerDependencies'] = {}
}
console.info(`Setting peer dependency on ${AlgoTsPackageName} to ${newVersion}`)
pkgJsonObj['peerDependencies'][AlgoTsPackageName] = newVersion

fs.writeFileSync('package.json', JSON.stringify(pkgJsonObj, undefined, 2))
console.info('Writing updated package.json')
3 changes: 3 additions & 0 deletions src/bin/run-cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

import '../cli'
9 changes: 7 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const cliArgumentsSchema = z.array(z.string())
function cli() {
const commander = new Command().name('puya-ts').description('Algo-TS to Algorand smart contract compiler')

commander.helpCommand(true)

commander
.command('build')
.argument('<paths...>', 'The path, or paths to search for compatible .algo.ts files')
Expand Down Expand Up @@ -122,7 +124,10 @@ function cli() {
}
})

commander.parse(process.argv)
if (process.argv.length < 3) {
commander.help()
} else {
commander.parse(process.argv)
}
}

cli()
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"include": [
"src/**/*.ts",
".tstoolkitrc.ts",
"scripts/**/*.ts",
"examples/**/*.ts",
"rollup.config.ts",
Expand Down

0 comments on commit a58e5b1

Please sign in to comment.