From bc8bf983f500c54d177141cdf0d921e54bc99594 Mon Sep 17 00:00:00 2001 From: thelamer Date: Mon, 18 Nov 2019 21:53:06 -0800 Subject: [PATCH] adding build logic pointed at netboot us-east buckets, semi loop tested --- .travis.yml | 76 ++++++++++++++++++++++++++++++++++++++------ script/build_release | 28 ++++++++++++++++ script/index.html | 16 +++++----- script/message | 11 +++++-- script/pre_install | 3 +- 5 files changed, 112 insertions(+), 22 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3212a38a..6a720694 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,38 +24,96 @@ jobs: bucket: $BUCKET_DEV local_dir: s3out upload-dir: $TRAVIS_COMMIT - region: us-west-2 skip_cleanup: true on: branch: development after_deploy: - ./script/message dev-push + + - stage: pull-request if: type = pull_request script: - - echo test + - ./script/build_release pr + + - stage: release-canidate if: branch = development AND tag IS present AND type != pull_request - script: - - echo test - - stage: release - if: branch = master AND type != pull_request before_install: - ./script/pre_install script: - - echo test + - ./script/build_release rc + after_failure: + - ./script/message failure deploy: - provider: s3 access_key_id: $AWS_ACCESS_KEY_ID secret_access_key: $AWS_SECRET_ACCESS_KEY bucket: $BUCKET_LIVE - local_dir: s3out + local_dir: s3out-latest + upload-dir: rc skip_cleanup: true + on: + branch: development + - provider: s3 + access_key_id: $AWS_ACCESS_KEY_ID + secret_access_key: $AWS_SECRET_ACCESS_KEY + bucket: $BUCKET_LIVE + local_dir: s3out + upload-dir: $TRAVIS_TAG + skip_cleanup: true + on: + branch: development + - provider: releases + api_key: $GITHUB_TOKEN + file_glob: true + file: githubout/* + prerelease: true + skip_cleanup: true + on: + branch: development + after_deploy: + - aws configure set preview.cloudfront true + - aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DIST_ID_BOOT --paths "rc/*" "rc/ipxe/*" + - ./script/message rc-push + + - stage: release + if: branch = master AND type != pull_request + before_install: + - ./script/pre_install + script: + - ./script/build_release release + after_failure: + - ./script/message failure + before_deploy: + - export RELEASE_TAG=$(cat version.txt) + - git tag ${RELEASE_TAG} + deploy: + - provider: s3 + access_key_id: $AWS_ACCESS_KEY_ID + secret_access_key: $AWS_SECRET_ACCESS_KEY + bucket: $BUCKET_LIVE + local_dir: s3out-latest + skip_cleanup: true + on: + branch: master + - provider: s3 + access_key_id: $AWS_ACCESS_KEY_ID + secret_access_key: $AWS_SECRET_ACCESS_KEY + bucket: $BUCKET_LIVE + local_dir: s3out + upload-dir: $RELEASE_TAG + skip_cleanup: true + on: + branch: master - provider: releases api_key: $GITHUB_TOKEN file_glob: true file: githubout/* skip_cleanup: true + on: + branch: development after_deploy: - aws configure set preview.cloudfront true - - aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DIST_ID_BOOT --paths "/*" + - aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DIST_ID_BOOT --paths "/*" "/ipxe/*" + - ./script/message live-push diff --git a/script/build_release b/script/build_release index af33e537..fa798c41 100755 --- a/script/build_release +++ b/script/build_release @@ -5,6 +5,12 @@ TYPE=$1 # Set boot domain if [[ "${TYPE}" == "dev" ]]; then BOOT_DOMAIN="${BUCKET_DEV}.s3-us-west-2.amazonaws.com/${TRAVIS_COMMIT}" +elif [[ "${TYPE}" == "pr" ]]; then + BOOT_DOMAIN="test.com" +elif [[ "${TYPE}" == "rc" ]]; then + BOOT_DOMAIN="boot.netboot.xyz/${TRAVIS_TAG}" +elif [[ "${TYPE}" == "release" ]]; then + BOOT_DOMAIN="boot.netboot.xyz/$(cat verion.txt)" fi sed -i \ "/^#boot_domain/c\boot_domain: ${BOOT_DOMAIN}" \ @@ -26,3 +32,25 @@ tar -czf menus.tar.gz * mv menus.tar.gz ../githubout cd .. + +# Latest style endpoints for RC and Live +if [[ "${TYPE}" == "release" ]] || [[ "${TYPE}" == "rc" ]]; then + rm -Rf buildout/ + if [[ "${TYPE}" == "release" ]]; then + sed -i \ + "/^boot_domain/c\boot_domain: boot.netboot.xyz" \ + user_overrides.yml + docker build -t localbuild -f Dockerfile-build . + docker run --rm -it -v $(pwd):/buildout localbuild + fi + if [[ "${TYPE}" == "rc" ]]; then + sed -i \ + "/^boot_domain/c\boot_domain: boot.netboot.xyz/rc" \ + user_overrides.yml + docker build -t localbuild -f Dockerfile-build . + docker run --rm -it -v $(pwd):/buildout localbuild + fi + mkdir -p s3out-latest + cp -r buildout/* s3out-latest/ + cp script/index.html s3out-latest/ +fi diff --git a/script/index.html b/script/index.html index f03dad40..3ed41024 100644 --- a/script/index.html +++ b/script/index.html @@ -4,13 +4,13 @@ Netboot.xyz BootLoaders - netboot.xyz.iso - netboot.xyz-efi.iso - netboot.xyz.dsk - netboot.xyz.usb - netboot.xyz.lkrn - netboot.xyz.kpxe - netboot.xyz-undionly.kpxe - netboot.xyz.efi + netboot.xyz.iso
+ netboot.xyz-efi.iso
+ netboot.xyz.dsk
+ netboot.xyz.usb
+ netboot.xyz.lkrn
+ netboot.xyz.kpxe
+ netboot.xyz-undionly.kpxe
+ netboot.xyz.efi
diff --git a/script/message b/script/message index e3abeae8..ff26d06a 100755 --- a/script/message +++ b/script/message @@ -3,9 +3,14 @@ TYPE=$1 if [ "${TYPE}" == "dev-push" ]; then - BOOT_URL="https://${BUCKET_DEV}.s3-us-west-2.amazonaws.com/${TRAVIS_COMMIT}/index.html" + BOOT_URL="https://${BUCKET_DEV}.s3-us-east-1.amazonaws.com/${TRAVIS_COMMIT}/index.html" +elif [ "${TYPE}" == "rc-push" ]; then + BOOT_URL="https://boot.netboot.xyz/${TRAVIS_TAG}/index.html" +elif [ "${TYPE}" == "live-push" ]; then + BOOT_URL="https://boot.netboot.xyz/$(cat version.txt)/index.html" fi + # send status to discord if [ "${TYPE}" == "failure" ]; then curl -X POST --data \ @@ -14,7 +19,7 @@ if [ "${TYPE}" == "failure" ]; then "embeds": [ { "color": 16711680, - "description": "__**Failed to Build**__ \n**Build:** '${TRAVIS_BUILD_WEB_URL}'\n**External Version:** '${EXTERNAL_VERSION}'\n**Status:** Failure\n**Change:** https://github.com/netbootxyz/netboot.xyz/commit/'${TRAVIS_COMMIT}'\n" + "description": "__**Failed to Build**__ \n**Build:** '${TRAVIS_BUILD_WEB_URL}'\n**Status:** Failure\n**Change:** https://github.com/netbootxyz/netboot.xyz/commit/'${TRAVIS_COMMIT}'\n" } ], "username": "Travis CI" @@ -27,7 +32,7 @@ else "embeds": [ { "color": 1681177, - "description": "__**Boot Menu Published**__ \n**Files:** '${BOOT_URL}' \n**Build:** '${TRAVIS_BUILD_WEB_URL}'\n**External Version:** '${EXTERNAL_VERSION}'\n**Change:** https://github.com/netbootxyz/netboot.xyz/commit/'${TRAVIS_COMMIT}'\n" + "description": "__**Boot Menu Published**__ \n**Files:** '${BOOT_URL}' \n**Build:** '${TRAVIS_BUILD_WEB_URL}'\n**Change:** https://github.com/netbootxyz/netboot.xyz/commit/'${TRAVIS_COMMIT}'\n" } ], "username": "Travis CI" diff --git a/script/pre_install b/script/pre_install index 67300dc4..9eb8deea 100755 --- a/script/pre_install +++ b/script/pre_install @@ -1,5 +1,4 @@ #!/bin/bash # Install aws cli - -pip install --user awscli tornado +sudo pip install awscli tornado