Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Tag releases in npm based on release channel for algots #183

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions .github/workflows/ci-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,6 @@ jobs:
working-directory: packages/algo-ts
upload-artifact-name: algo-ts
upload-artifact-path: ./packages/algo-ts/dist
post-build-script: |
cd dist
set +e # Continue on error
thisVersion=$(npm view ./ version)
diffText=$(npm diff --diff=./ --diff=@algorandfoundation/algorand-typescript@$thisVersion)
diffExitCode=$?
set -e # Exit on error
[ $diffExitCode -ne 0 ] && (echo "$thisVersion has not been published yet"; exit 0;) || echo "$thisVersion already published, checking diff against local build"
diffTextLen=${#diffText}
[ $diffTextLen -eq 0 ] && echo 'No changes' || (echo 'ERROR: Code differs to published version. Please bump package version or revert changes'; echo $diffText; exit 1;)

ci-puya-ts:
name: 'Build @algorandfoundation/puya-ts'
Expand All @@ -50,3 +40,17 @@ jobs:
algokit localnet reset --update
test-script: npm run test:ci
output-test-results: true

publish-deployment-artifact:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 'Publish deployment artifacts'
uses: actions/upload-artifact@v4
with:
name: scripts
path: ./scripts
12 changes: 7 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,20 @@ jobs:
with:
path: artifacts

- name: Generate semantic version for @algorandfoundation/puya-ts
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish @algorandfoundation/algorand-typescript
uses: JS-DevTools/npm-publish@v3
id: publish-algo-ts
with:
token: ${{ secrets.NPM_TOKEN }}
package: artifacts/algo-ts/package.json
access: 'public'

- name: Generate semantic version for @algorandfoundation/puya-ts
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Tagging 'main' branch with latest for now, even though it's beta because we don't have a non-beta
tag: ${{ github.ref_name == 'alpha' && 'alpha' || github.ref_name == 'main' && 'latest' || github.ref_name == 'release' && 'latest' || 'pre-release' }}

- name: Publish @algorandfoundation/puya-ts
uses: JS-DevTools/npm-publish@v3
Expand Down
6 changes: 6 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@
"pkgRoot": "artifacts/puya-ts"
}
],
[
"@semantic-release/exec",
{
"prepareCmd": "npx tsx artifacts/scripts/update-algo-ts-version.ts ${nextRelease.version}"
}
],
"@semantic-release/github"
]
}
15 changes: 15 additions & 0 deletions scripts/update-algo-ts-version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env node

/* This script updates the version of algo-ts in the package.json file
* of the algo-ts package . It is triggered in the release pipeline of
* the algo-ts package. It takes the version as an argument and updates
* the package.json file accordingly. This is useful for keeping the version
* of algo-ts in sync with the version of the puya-ts package.
*/

import fs from 'fs'
import algotsPackage from '../algo-ts/package.json'

const args = process.argv.slice(2)
algotsPackage.version = args[0]
fs.writeFileSync('artifacts/algo-ts/package.json', JSON.stringify(algotsPackage, null, 2))
7 changes: 2 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"extends": "@tsconfig/node20/tsconfig.json",
"compilerOptions": {
"lib": [
"ESNext"
],
"lib": ["ESNext"],
"noEmit": true,
"target": "ES2023",
"module": "ESNext",
Expand All @@ -25,6 +23,5 @@
"vitest.config.mts",
"eslint.config.mjs"
],
"exclude": ["packages/**/*.ts"],

"exclude": ["packages/**/*.ts", "scripts/update-algo-ts-version.ts"]
}