Adding logs #34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Release | |
on: | |
push: | |
branches: [ fabisev/artifact-publishing ] | |
tags: [ 'v*', 'rc-*' ] | |
pull_request: | |
branches: [ main ] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: | |
- project-awsaws-lambda-nodejs-runtime-interface-client | |
timeout-minutes: 15 | |
outputs: | |
version: ${{ steps.version.outputs.version }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
cache: 'npm' | |
- name: Get version | |
id: version | |
run: | | |
BASE_VERSION=$(node -p "require('./package.json').version") | |
echo "version=$BASE_VERSION" >> $GITHUB_OUTPUT | |
- name: Cache native dependencies | |
uses: actions/cache@v4 | |
with: | |
path: | | |
deps/ | |
build/ | |
key: native-deps-${{ runner.os }}-${{ hashFiles('deps/versions', 'binding.gyp') }} | |
- name: Install build dependencies | |
run: yum install -y cmake make gcc-c++ | |
- name: Clean build directories | |
run: rm -rf deps/*/build | |
- name: Install dependencies | |
run: | | |
echo "Starting npm ci..." | |
npm ci --verbose | |
echo "npm ci completed" | |
- name: Build project | |
run: | | |
echo "Starting npm run build..." | |
npm run build | |
echo "Build completed" | |
- name: Pack project | |
run: | | |
echo "Starting npm pack..." | |
npm pack | |
echo "Pack completed" | |
- name: Generate checksums | |
run: | | |
PACKAGE_FILE=$(ls aws-lambda-ric-*.tgz) | |
sha256sum $PACKAGE_FILE > checksums.sha256 | |
sha512sum $PACKAGE_FILE > checksums.sha512 | |
cat checksums.sha256 checksums.sha512 > checksums.txt | |
echo "Package: $PACKAGE_FILE with version: ${{ steps.version.outputs.version }}" >> checksums.txt | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: package-${{ steps.version.outputs.version }} | |
path: | | |
aws-lambda-ric-*.tgz | |
checksums.* | |
retention-days: 30 | |
test: | |
runs-on: | |
- project-awsaws-lambda-nodejs-runtime-interface-client | |
needs: [build] | |
strategy: | |
matrix: | |
node-version: [18, 20, 22] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Run unit tests - Node ${{ matrix.node-version }} | |
run: | | |
docker build -f test/unit/Dockerfile.nodejs${{ matrix.node-version }}.x -t unit/nodejs.${{ matrix.node-version }}x . | |
docker run --rm unit/nodejs.${{ matrix.node-version }}x | |
publish: | |
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/fabisev/artifact-publishing' | |
runs-on: | |
- project-awsaws-lambda-nodejs-runtime-interface-client | |
needs: [build, test] | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: package-${{ needs.build.outputs.version }} | |
- name: Verify checksums | |
run: | | |
sha256sum -c checksums.sha256 | |
sha512sum -c checksums.sha512 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: Setup NPM authentication | |
run: | | |
NPM_TOKEN=$(aws secretsmanager get-secret-value --secret-id aws-lambda-runtimes/github/nodejs/npm-token --query SecretString --output text) | |
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc | |
- name: Determine version and package name | |
id: version | |
run: | | |
if [[ "${{ github.ref }}" == refs/heads/fabisev/artifact-publishing ]]; then | |
# For branch testing, use a scoped package name and test version | |
PACKAGE_VERSION="${{ needs.build.outputs.version }}-test.$(date +%s)" | |
echo "package_version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT | |
echo "is_test=true" >> $GITHUB_OUTPUT | |
echo "is_rc=false" >> $GITHUB_OUTPUT | |
# Change package name to avoid conflicts | |
npm pkg set name="avocado-toast" | |
npm version $PACKAGE_VERSION --no-git-tag-version | |
elif [[ "${{ github.ref }}" == refs/tags/rc-* ]]; then | |
RC_NUMBER=${GITHUB_REF#refs/tags/rc-} | |
PACKAGE_VERSION="${{ needs.build.outputs.version }}-rc.${RC_NUMBER}" | |
echo "package_version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT | |
echo "is_test=false" >> $GITHUB_OUTPUT | |
echo "is_rc=true" >> $GITHUB_OUTPUT | |
npm version $PACKAGE_VERSION --no-git-tag-version | |
else | |
echo "package_version=${{ needs.build.outputs.version }}" >> $GITHUB_OUTPUT | |
echo "is_test=false" >> $GITHUB_OUTPUT | |
echo "is_rc=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Publish to npm | |
run: | | |
if [[ "${{ steps.version.outputs.is_test }}" == "true" ]]; then | |
npm publish aws-lambda-ric-*.tgz --tag test | |
elif [[ "${{ steps.version.outputs.is_rc }}" == "true" ]]; then | |
npm publish aws-lambda-ric-*.tgz --tag rc | |
else | |
npm publish aws-lambda-ric-*.tgz | |
fi | |
- name: Generate and Update Changelog | |
if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
node scripts/generate-changelog.js --output release-notes.md | |
node scripts/generate-changelog.js --update | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add RELEASE.CHANGELOG.md | |
git commit -m "Update changelog for ${{ steps.version.outputs.package_version }}" || echo "No changes to commit" | |
echo "Generated release notes:" | |
cat release-notes.md | |
- name: Create GitHub Release | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: | | |
aws-lambda-ric-*.tgz | |
checksums.sha256 | |
checksums.sha512 | |
checksums.txt | |
prerelease: ${{ steps.version.outputs.is_rc }} | |
name: ${{ steps.version.outputs.is_rc == 'true' && format('Release Candidate {0}', steps.version.outputs.package_version) || '' }} | |
body_path: release-notes.md |