Skip to content

Update UglifyJS

Update UglifyJS #125

Workflow file for this run

name: CI
on:
pull_request:
branches:
- master
push:
branches:
- master
- issue/*
# - dev/harai
env:
AWS_ACCOUNT_ID: '013230744746'
TEST_ACCESS_KEY_ID: AKIAQGFE5ESVOSITRJJK
TEST_S3_SRC_BUCKET: gutenberg-ext-imgconv-tests3srcbucket-1nfmay8h6zit1
TEST_S3_DEST_BUCKET: gutenberg-ext-imgconv-tests3destbucket-a6ao4v2r6ks5
TEST_S3_ANOTHER_SRC_BUCKET: gutenberg-ext-imgconv-tests3anothersrcbucket-1lj3632c3dn19
TEST_S3_ANOTHER_DEST_BUCKET: gutenberg-ext-imgconv-tests3anotherdestbucket-1xrab2bhory0u
RELEASE_ACCESS_KEY_ID: AKIAQGFE5ESVD2ODKAC5
REPO_BUCKET: gutenberg-ext-imgconv-repobucket-1bxd9jnafv4c5
GO_VERSION: 1.21.3
jobs:
build-go:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@main
- uses: actions/setup-go@main
with:
go-version: '~${{env.GO_VERSION}}'
- run: echo "$TEST_ACCESS_KEY_ID" > config/test/access-key-id
- run: echo "$AWS_ACCOUNT_ID" > config/test/aws-account-id
- run: echo "$TEST_S3_SRC_BUCKET" > config/test/s3-src-bucket
- run: echo "$TEST_S3_DEST_BUCKET" > config/test/s3-dest-bucket
- run: echo "$TEST_S3_ANOTHER_SRC_BUCKET" > config/test/s3-another-src-bucket
- run: echo "$TEST_S3_ANOTHER_DEST_BUCKET" > config/test/s3-another-dest-bucket
- run: echo "$TEST_SECRET_ACCESS_KEY" > config/test/secret-access-key
env:
TEST_SECRET_ACCESS_KEY: ${{secrets.AWS_TEST_SECRET_ACCESS_KEY}}
- run: sudo apt-get install -y gcc
- name: Generate build number
uses: onyxmueller/build-tag-number@main
with:
token: ${{secrets.GITHUB_TOKEN}}
prefix: build_number_generator
- name: Print new build number
run: echo "Build number is $BUILD_NUMBER"
- name: Save the build number
run: echo "$BUILD_NUMBER" > work/BUILD_NUMBER
- name: Embed build number into code
run: echo "build-$BUILD_NUMBER" > ./VERSION
- name: Build on the same machine image as AWS Lambda
# Add "safe.directory" to avoid "detected dubious ownership in repository" error.
run: |
cmd="$(
cat <<EOF
yum install -y git gcc tar binutils
cd /
curl -fsSL -o go.tar.gz https://go.dev/dl/go${{env.GO_VERSION}}.linux-amd64.tar.gz
tar -C /usr/local -xzf go.tar.gz
ln -s /usr/local/go/bin/go /usr/local/bin/go
cd /workspace
git config --global --add safe.directory /workspace
GOOS=linux GOARCH=amd64 go build \
-ldflags "-X github.com/tarosky/gutenberg-imgconv/imgconv.Version=$(< ./VERSION)" \
-tags lambda.norpc \
-o work/bootstrap \
lambda/lambda.go
EOF
)"
docker container run \
--rm \
--entrypoint /bin/bash \
--mount type=bind,source="$(pwd)",target=/workspace \
amazonlinux:2 \
-eux -c "$cmd"
- uses: actions/upload-artifact@main
with:
name: artifact-bootstrap
path: work/bootstrap
- uses: actions/upload-artifact@main
with:
name: build-number
path: work/BUILD_NUMBER
build-uglifyjs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@main
- run: uglifyjs/build-image
- run: uglifyjs/run-nexe
- uses: actions/upload-artifact@main
with:
name: artifact-uglifyjs
path: work/uglifyjs
test:
needs: build-uglifyjs
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@main
- uses: actions/download-artifact@main
with:
name: artifact-bootstrap
path: work
- uses: actions/download-artifact@main
with:
name: artifact-uglifyjs
path: work
- run: chmod +x work/uglifyjs
- uses: actions/setup-go@main
with:
go-version: '~${{env.GO_VERSION}}'
- run: echo "$TEST_ACCESS_KEY_ID" > config/test/access-key-id
- run: echo "$AWS_ACCOUNT_ID" > config/test/aws-account-id
- run: echo "$TEST_S3_SRC_BUCKET" > config/test/s3-src-bucket
- run: echo "$TEST_S3_DEST_BUCKET" > config/test/s3-dest-bucket
- run: echo "$TEST_S3_ANOTHER_SRC_BUCKET" > config/test/s3-another-src-bucket
- run: echo "$TEST_S3_ANOTHER_DEST_BUCKET" > config/test/s3-another-dest-bucket
- run: echo "$TEST_SECRET_ACCESS_KEY" > config/test/secret-access-key
env:
TEST_SECRET_ACCESS_KEY: ${{secrets.AWS_TEST_SECRET_ACCESS_KEY}}
- run: go get github.com/jstemmer/go-junit-report
- run: go install github.com/jstemmer/go-junit-report
- run: go test -v ./bootstrap 2>&1 | tee work/test.log
- run: go-junit-report < work/test.log > work/report.xml
- uses: actions/upload-artifact@main
with:
name: report.xml
path: work/report.xml
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@master
if: always()
with:
github_token: ${{secrets.GITHUB_TOKEN}}
files: work/report.xml
bundle:
needs:
- build-go
- build-uglifyjs
runs-on: ubuntu-20.04
steps:
- uses: actions/download-artifact@main
with:
name: artifact-bootstrap
- uses: actions/download-artifact@main
with:
name: artifact-uglifyjs
- run: chmod +x bootstrap uglifyjs
- run: zip -j imgconv.zip ./bootstrap ./uglifyjs
- uses: actions/upload-artifact@main
with:
name: artifact-imgconv
path: imgconv.zip
release:
needs:
- bundle
- test
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-20.04
steps:
- uses: actions/download-artifact@main
with:
name: artifact-imgconv
- uses: actions/download-artifact@main
with:
name: build-number
- name: set BUILD_NUMBER
run: echo "BUILD_NUMBER=$(< ./BUILD_NUMBER)" >> $GITHUB_ENV
- name: set ASSET_NAME
run: echo "ASSET_NAME=imgconv.build-$BUILD_NUMBER-awslambda-provided-amd64.zip" >> $GITHUB_ENV
- name: rename
run: cp imgconv.zip "$ASSET_NAME"
- id: create_release
uses: softprops/action-gh-release@master
with:
tag_name: build-${{env.BUILD_NUMBER}}
name: Build ${{env.BUILD_NUMBER}}
draft: false
prerelease: false
files: ${{env.ASSET_NAME}}
- uses: aws-actions/configure-aws-credentials@main
with:
aws-access-key-id: ${{env.RELEASE_ACCESS_KEY_ID}}
aws-secret-access-key: ${{secrets.AWS_RELEASE_SECRET_ACCESS_KEY}}
aws-region: ap-northeast-1
- run: aws s3 cp imgconv.zip "s3://$REPO_BUCKET/$ASSET_NAME"