Skip to content
Merged
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
4 changes: 3 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ jobs:
- uses: actions/checkout@v4
- uses: ./.github/actions/configure-nodejs
- name: Build
run: npm run build
run: |
npm run build
npm run build -w packages/lambda
- name: Cache cdk-construct build outputs
id: cdk_construct_cache
uses: actions/cache@v4
Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Package and Publish

# Controls when the action will run.
on:
release:
types: [published]
# push:
# branches:
# - main

jobs:
install-deps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/configure-nodejs
with:
lookup-only: 'true' # We only want to lookup from the cache - if a hit, this job does nothing

publish:
needs:
- install-deps
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4

- uses: ./.github/actions/configure-nodejs

# Note: We do NOT want to use `npm version` here to apply the version
# to the package.json files with `--workspaces`.
# `npm version --workspaces` will reinstall modules, defeating the purpose of caching
# `npm version --workspaces` will also update the package-lock.json and package.json
# files which will change our cache key and cause the node_modules
# to be saved to the cache at the end of this job, even though it didn't
# install the modules.
- name: Set version for PR or from Tag
run: |
VERSION_TO_USE=$(npm version from-git --allow-same-version --no-git-tag-version)
echo "Version is ${VERSION_TO_USE}"
scripts/version ${VERSION_TO_USE}

- name: Build
run: |
npm run build
npm run build -w packages/lambda

- name: Package the Construct
run: |
npm run compile -w packages/cdk-construct
npm run post-compile -w packages/cdk-construct
npm run test -w packages/cdk-construct
npm run package -w packages/cdk-construct

- name: NPM registry authentication
run: npm set //registry.npmjs.org/:_authToken ${{ secrets.NPMJSORG_PUBLISH_TOKEN }}

- name: Release cdk-construct - NPM
id: cdk-construct-npm
working-directory: packages/cdk-construct
run: |
npm publish
2 changes: 1 addition & 1 deletion packages/cdk-construct/src/construct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface CrushTestProps {
/**
* The Docker image code to use for the Lambda.
* This should be a DockerImageCode instance, typically from an ECR asset or image URI.
*
*
* @default A Docker image built from the local Dockerfile and bundled JS in the `lambda` directory.
*/
readonly dockerImageCode?: lambda.DockerImageCode;
Expand Down
43 changes: 43 additions & 0 deletions scripts/version
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env node

const glob = require('glob');
const fs = require('fs');
const path = require('path');
const semver = require('semver');

// Get the new version from the command-line arguments
let newVersion = process.argv[2];

if (!newVersion) {
console.error('Please provide a version as the first argument.');
console.log(`Usage: node ${path.relative(process.cwd(), process.argv[1])} x.y.z`);
process.exit(1);
}

newVersion = newVersion.replace(/.*\//, '').replace(/^v/, '');

// Validate the new version
if (!semver.valid(newVersion)) {
console.error(
'Invalid version. Please provide a version in the format x.y.z as the first argument.',
);
console.log(`Usage: node ${path.relative(process.cwd(), process.argv[1])} x.y.z`);
process.exit(1);
}

glob(
'**/package.json',
{ ignore: ['node_modules/**', 'dist/**', 'cdk.out/**', 'coverage/**'] },
(err, files) => {
if (err) {
console.error(err);
process.exit(1);
}

files.forEach((file) => {
const pkg = JSON.parse(fs.readFileSync(file, 'utf-8'));
pkg.version = newVersion;
fs.writeFileSync(file, JSON.stringify(pkg, null, 2) + '\n');
});
},
);