-
Notifications
You must be signed in to change notification settings - Fork 59
Fabisev/artifact publishing #149
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
Open
fabisev
wants to merge
36
commits into
main
Choose a base branch
from
fabisev/artifact-publishing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
51be34d
Creating github actions workflow with publishing pipeline
88a021d
Adding Copyright headers, header checking script and header writing s…
98ab5eb
Adding rc publishing
5bdfeb3
Commenting lint for now
faaa65f
Testing release
1dc8f90
Adding automated changelog generation
f8c8ad5
Refactoring automated changelog generation
39ab54c
Adding codebuild to the build
5e88c22
Adding the necessary dependencies for codebuild
a9d4d66
Fixing build
5a8defe
Fixing build
86b1fe4
Checking npm publishing
cdc0773
Changing the codebuild
9770fa8
Testing npm publishing using codebuild
0cae97e
Adding logs
eeecccb
Checking build on codebuild
e69a19d
Fixing build on codebuild
3bcd7ea
Fixing build on codebuild
cad8992
Fixing build on codebuild
c645473
Preparing github actions workflow for merge with main
201b966
Solving conflicts
bdb6bf1
Changing npm publishing
331b87e
removing shebang line
7e18147
Adding echo for easier debugging and check if docker is avail
d731168
Adding specific error message for different node versions and formatiing
523de7c
Adding build and publishing for both architectures
160d714
Making the add and check headers scripts use git diff and patches
595e7e8
Making headers scripts use patch files
50265d9
Adding architecture specific tar
61c7c17
FIxing build
9e5bc37
Changing permissions position, node version, npm token, check-headers
1706f42
Remove hardcoded Node.js 16 target from build script
81a4774
Changing add headers and check headers
f45fccb
Merge pull request #156 from aws/main
fabisev 8170ee6
Split build and release workflows
eef3212
Simplify workflow matrix and remove empty permissions
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
get-version: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
outputs: | ||
version: ${{ steps.version.outputs.version }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Get version | ||
id: version | ||
run: | | ||
BASE_VERSION=$(node -p "require('./package.json').version") | ||
echo "version=$BASE_VERSION" >> $GITHUB_OUTPUT | ||
|
||
build: | ||
needs: [get-version] | ||
timeout-minutes: 30 | ||
permissions: | ||
id-token: write | ||
contents: read | ||
strategy: | ||
matrix: | ||
arch: [x86_64, aarch64] | ||
runs-on: codebuild-project-awsaws-lambda-nodejs-runtime-interface-client-${{ github.run_id }}-${{ github.run_attempt }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 'lts/*' | ||
|
||
- name: Check copyright headers | ||
run: npm run check-headers | ||
|
||
- name: Install build dependencies | ||
run: | | ||
apt-get update | ||
apt-get install -y cmake make g++ autotools-dev automake libtool | ||
|
||
- name: Build natively for ${{ matrix.arch }} | ||
run: | | ||
echo "Building for architecture: ${{ matrix.arch }}" | ||
|
||
# Build native dependencies and JavaScript | ||
BUILD=1 npm install | ||
npm run build | ||
|
||
# Verify required files were created | ||
if [ ! -f "dist/rapid-client.node" ] || [ ! -f "dist/index.mjs" ] || [ ! -f "dist/UserFunction.js" ]; then | ||
echo "Error: Required files not found in dist directory" | ||
exit 1 | ||
fi | ||
|
||
# Copy architecture-specific package.json to dist | ||
node -e " | ||
const pkg = require('./package.json'); | ||
pkg.name = 'aws-lambda-ric-${{ matrix.arch }}'; | ||
require('fs').writeFileSync('./dist/package.json', JSON.stringify(pkg, null, 2)); | ||
" | ||
|
||
# Create tarball with only required files | ||
tar -czf aws-lambda-ric-${{ matrix.arch }}-${{ needs.get-version.outputs.version }}.tgz \ | ||
-C dist package.json index.mjs UserFunction.js rapid-client.node | ||
|
||
- name: Generate checksums | ||
run: | | ||
PACKAGE_FILE="aws-lambda-ric-${{ matrix.arch }}-${{ needs.get-version.outputs.version }}.tgz" | ||
sha256sum $PACKAGE_FILE > checksums-${{ matrix.arch }}.sha256 | ||
sha512sum $PACKAGE_FILE > checksums-${{ matrix.arch }}.sha512 | ||
echo "Package: $PACKAGE_FILE (${{ matrix.arch }}) with version: ${{ needs.get-version.outputs.version }}" > checksums-${{ matrix.arch }}.txt | ||
|
||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: package-${{ matrix.arch }}-${{ needs.get-version.outputs.version }} | ||
path: | | ||
aws-lambda-ric-*-${{ needs.get-version.outputs.version }}.tgz | ||
checksums-* | ||
retention-days: 30 | ||
|
||
test: | ||
needs: [get-version, build] | ||
permissions: | ||
contents: read | ||
strategy: | ||
matrix: | ||
node-version: [18, 20, 22] | ||
include: | ||
- arch: x86_64 | ||
runner: ubuntu-latest | ||
- arch: aarch64 | ||
runner: ubuntu-latest | ||
runs-on: ${{ matrix.runner }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Run unit tests - Node ${{ matrix.node-version }} (native $(arch)) | ||
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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
name: Release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
description: 'Release tag (e.g., v1.0.0 or rc-1)' | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
get-version: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
outputs: | ||
version: ${{ steps.version.outputs.version }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Get version | ||
id: version | ||
run: | | ||
BASE_VERSION=$(node -p "require('./package.json').version") | ||
echo "version=$BASE_VERSION" >> $GITHUB_OUTPUT | ||
|
||
build: | ||
needs: [get-version] | ||
timeout-minutes: 30 | ||
permissions: | ||
id-token: write | ||
contents: read | ||
strategy: | ||
matrix: | ||
arch: [x86_64, aarch64] | ||
runs-on: codebuild-project-awsaws-lambda-nodejs-runtime-interface-client-${{ github.run_id }}-${{ github.run_attempt }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 'lts/*' | ||
|
||
- name: Install build dependencies | ||
run: | | ||
apt-get update | ||
apt-get install -y cmake make g++ autotools-dev automake libtool | ||
|
||
- name: Build natively for ${{ matrix.arch }} | ||
run: | | ||
echo "Building for architecture: ${{ matrix.arch }}" | ||
|
||
# Build native dependencies and JavaScript | ||
BUILD=1 npm install | ||
npm run build | ||
|
||
# Verify required files were created | ||
if [ ! -f "dist/rapid-client.node" ] || [ ! -f "dist/index.mjs" ] || [ ! -f "dist/UserFunction.js" ]; then | ||
echo "Error: Required files not found in dist directory" | ||
exit 1 | ||
fi | ||
|
||
# Copy architecture-specific package.json to dist | ||
node -e " | ||
const pkg = require('./package.json'); | ||
pkg.name = 'aws-lambda-ric-${{ matrix.arch }}'; | ||
require('fs').writeFileSync('./dist/package.json', JSON.stringify(pkg, null, 2)); | ||
" | ||
|
||
# Create tarball with only required files | ||
tar -czf aws-lambda-ric-${{ matrix.arch }}-${{ needs.get-version.outputs.version }}.tgz \ | ||
-C dist package.json index.mjs UserFunction.js rapid-client.node | ||
|
||
- name: Generate checksums | ||
run: | | ||
PACKAGE_FILE="aws-lambda-ric-${{ matrix.arch }}-${{ needs.get-version.outputs.version }}.tgz" | ||
sha256sum $PACKAGE_FILE > checksums-${{ matrix.arch }}.sha256 | ||
sha512sum $PACKAGE_FILE > checksums-${{ matrix.arch }}.sha512 | ||
echo "Package: $PACKAGE_FILE (${{ matrix.arch }}) with version: ${{ needs.get-version.outputs.version }}" > checksums-${{ matrix.arch }}.txt | ||
|
||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: package-${{ matrix.arch }}-${{ needs.get-version.outputs.version }} | ||
path: | | ||
aws-lambda-ric-*-${{ needs.get-version.outputs.version }}.tgz | ||
checksums-* | ||
retention-days: 30 | ||
|
||
publish: | ||
runs-on: codebuild-project-awsaws-lambda-nodejs-runtime-interface-client-${{ github.run_id }}-${{ github.run_attempt }} | ||
needs: [get-version, build] | ||
permissions: | ||
id-token: write | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Download x86_64 artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: package-x86_64-${{ needs.get-version.outputs.version }} | ||
path: ./artifacts/x86_64 | ||
|
||
- name: Download aarch64 artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: package-aarch64-${{ needs.get-version.outputs.version }} | ||
path: ./artifacts/aarch64 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 'lts/*' | ||
|
||
- name: Setup NPM authentication | ||
run: | | ||
NPM_TOKEN=$(aws secretsmanager get-secret-value --secret-id ${{ secrets.NPM_SECRET_NAME }} --query SecretString --output text) | ||
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc | ||
chmod 0600 .npmrc | ||
|
||
- name: Create and push tag | ||
run: | | ||
git config --global user.name "github-actions[bot]" | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
git tag ${{ inputs.tag }} | ||
git push origin ${{ inputs.tag }} | ||
|
||
- name: Determine version and publish packages | ||
id: version | ||
run: | | ||
if [[ "${{ inputs.tag }}" == rc-* ]]; then | ||
RC_NUMBER=${GITHUB_REF#refs/tags/rc-} | ||
PACKAGE_VERSION="${{ needs.get-version.outputs.version }}-rc.${RC_NUMBER}" | ||
echo "package_version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT | ||
echo "is_rc=true" >> $GITHUB_OUTPUT | ||
TAG_FLAG="--tag rc" | ||
else | ||
echo "package_version=${{ needs.get-version.outputs.version }}" >> $GITHUB_OUTPUT | ||
TAG_FLAG="" | ||
fi | ||
|
||
# Build and publish full package to npm | ||
BUILD=1 npm install | ||
npm run build | ||
npm publish $TAG_FLAG --access=public | ||
|
||
- name: Combine checksums | ||
run: | | ||
cat ./artifacts/*/checksums-*.txt > combined-checksums.txt | ||
cat ./artifacts/*/checksums-*.sha256 > combined-checksums.sha256 | ||
cat ./artifacts/*/checksums-*.sha512 > combined-checksums.sha512 | ||
|
||
- name: Create GitHub Release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
tag_name: ${{ inputs.tag }} | ||
files: | | ||
./artifacts/*/aws-lambda-ric-*-*.tgz | ||
combined-checksums.* | ||
prerelease: ${{ steps.version.outputs.is_rc }} |
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for updating the readme!