Selaa lähdekoodia

adding build logic pointed at netboot us-east buckets, semi loop tested

thelamer 5 vuotta sitten
vanhempi
commit
bc8bf983f5
5 muutettua tiedostoa jossa 108 lisäystä ja 18 poistoa
  1. 63 5
      .travis.yml
  2. 28 0
      script/build_release
  3. 8 8
      script/index.html
  4. 8 3
      script/message
  5. 1 2
      script/pre_install

+ 63 - 5
.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
+      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-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:
-        - echo test
+        - ./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

+ 28 - 0
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

+ 8 - 8
script/index.html

@@ -4,13 +4,13 @@
     <title>Netboot.xyz BootLoaders</title>
   </head>
   <body>
-  <a href="ipxe/netboot.xyz.iso">netboot.xyz.iso</a>
-  <a href="ipxe/netboot.xyz-efi.iso">netboot.xyz-efi.iso</a>
-  <a href="ipxe/netboot.xyz.dsk">netboot.xyz.dsk</a>
-  <a href="ipxe/netboot.xyz.usb">netboot.xyz.usb</a>
-  <a href="ipxe/netboot.xyz.lkrn">netboot.xyz.lkrn</a>
-  <a href="ipxe/netboot.xyz.kpxe">netboot.xyz.kpxe</a>
-  <a href="ipxe/netboot.xyz-undionly.kpxe">netboot.xyz-undionly.kpxe</a>
-  <a href="ipxe/netboot.xyz.efi">netboot.xyz.efi</a>
+  <a href="ipxe/netboot.xyz.iso">netboot.xyz.iso</a><br>
+  <a href="ipxe/netboot.xyz-efi.iso">netboot.xyz-efi.iso</a><br>
+  <a href="ipxe/netboot.xyz.dsk">netboot.xyz.dsk</a><br>
+  <a href="ipxe/netboot.xyz.usb">netboot.xyz.usb</a><br>
+  <a href="ipxe/netboot.xyz.lkrn">netboot.xyz.lkrn</a><br>
+  <a href="ipxe/netboot.xyz.kpxe">netboot.xyz.kpxe</a><br>
+  <a href="ipxe/netboot.xyz-undionly.kpxe">netboot.xyz-undionly.kpxe</a><br>
+  <a href="ipxe/netboot.xyz.efi">netboot.xyz.efi</a><br>
   </body>
 </html>

+ 8 - 3
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"

+ 1 - 2
script/pre_install

@@ -1,5 +1,4 @@
 #!/bin/bash
 
 # Install aws cli
-
-pip install --user awscli tornado
+sudo pip install awscli tornado