|
| 1 | +name: Nightly build |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # run every day at 1AM |
| 6 | + - cron: "0 1 * * *" |
| 7 | + |
| 8 | +jobs: |
| 9 | + create-nightly-artifacts: |
| 10 | + # This workflow is only of value to the arduino/arduino-arduino-lint repository and |
| 11 | + # would always fail in forks |
| 12 | + if: github.repository == 'arduino/arduino-lint' |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Checkout |
| 17 | + uses: actions/checkout@v2 |
| 18 | + |
| 19 | + - name: Install Taskfile |
| 20 | + uses: arduino/actions/setup-taskfile@master |
| 21 | + with: |
| 22 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 23 | + version: 3.x |
| 24 | + |
| 25 | + - name: Build |
| 26 | + env: |
| 27 | + CUSTOM_VERSION: nightly |
| 28 | + run: task dist:all |
| 29 | + |
| 30 | + - name: Upload artifacts |
| 31 | + uses: actions/upload-artifact@v2 |
| 32 | + with: |
| 33 | + name: dist |
| 34 | + path: dist |
| 35 | + |
| 36 | + notarize-macos: |
| 37 | + runs-on: macos-latest |
| 38 | + needs: create-nightly-artifacts |
| 39 | + |
| 40 | + steps: |
| 41 | + - name: Checkout |
| 42 | + uses: actions/checkout@v2 |
| 43 | + |
| 44 | + - name: Download artifacts |
| 45 | + uses: actions/download-artifact@v2 |
| 46 | + with: |
| 47 | + name: dist |
| 48 | + # to ensure compatibility with v1 |
| 49 | + path: dist |
| 50 | + |
| 51 | + - name: Import Code-Signing Certificates |
| 52 | + env: |
| 53 | + KEYCHAIN: "sign.keychain" |
| 54 | + INSTALLER_CERT_MAC_PATH: "/tmp/ArduinoCerts2020.p12" |
| 55 | + KEYCHAIN_PASSWORD: keychainpassword # Arbitrary password for a keychain that exists only for the duration of the job, so not secret |
| 56 | + run: | |
| 57 | + echo "${{ secrets.INSTALLER_CERT_MAC_P12 }}" | base64 --decode > ${{ env.INSTALLER_CERT_MAC_PATH }} |
| 58 | + security create-keychain -p ${{ env.KEYCHAIN_PASSWORD }} ${{ env.KEYCHAIN }} |
| 59 | + security default-keychain -s ${{ env.KEYCHAIN }} |
| 60 | + security unlock-keychain -p ${{ env.KEYCHAIN_PASSWORD }} ${{ env.KEYCHAIN }} |
| 61 | + security import ${{ env.INSTALLER_CERT_MAC_PATH }} -k ${{ env.KEYCHAIN }} -f pkcs12 -A -T /usr/bin/codesign -P ${{ secrets.INSTALLER_CERT_MAC_PASSWORD }} |
| 62 | + security set-key-partition-list -S apple-tool:,apple: -s -k ${{ env.KEYCHAIN_PASSWORD }} ${{ env.KEYCHAIN }} |
| 63 | +
|
| 64 | + - name: Install gon for code signing and app notarization |
| 65 | + run: | |
| 66 | + wget -q https://github.com/mitchellh/gon/releases/download/v0.2.3/gon_macos.zip |
| 67 | + unzip gon_macos.zip -d /usr/local/bin |
| 68 | +
|
| 69 | + - name: Sign and notarize binary |
| 70 | + env: |
| 71 | + AC_USERNAME: ${{ secrets.AC_USERNAME }} |
| 72 | + AC_PASSWORD: ${{ secrets.AC_PASSWORD }} |
| 73 | + run: | |
| 74 | + gon gon.config.hcl |
| 75 | +
|
| 76 | + - name: Re-package binary and update checksum |
| 77 | + # This step performs the following: |
| 78 | + # 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file) |
| 79 | + # 2. Recalculate package checksum and replace it in the goreleaser nnnnnn-checksums.txt file |
| 80 | + run: | |
| 81 | + # GitHub's upload/download-artifact@v2 action doesn't preserve file permissions, |
| 82 | + # so we need to add execution permission back until the action is made to do this. |
| 83 | + chmod +x dist/arduino-lint_osx_darwin_amd64/arduino-lint |
| 84 | + PACKAGE_FILENAME="$(basename dist/arduino-lint_nightly-*_macOS_64bit.tar.gz)" |
| 85 | + tar -czvf dist/$PACKAGE_FILENAME \ |
| 86 | + -C dist/arduino-lint_osx_darwin_amd64/ arduino-lint \ |
| 87 | + -C ../../ LICENSE.txt |
| 88 | + CLI_CHECKSUM=$(shasum -a 256 dist/$PACKAGE_FILENAME | cut -d " " -f 1) |
| 89 | + perl -pi -w -e "s/.*${PACKAGE_FILENAME}/${CLI_CHECKSUM} ${PACKAGE_FILENAME}/g;" dist/*-checksums.txt |
| 90 | +
|
| 91 | + - name: Upload artifacts |
| 92 | + uses: actions/upload-artifact@v2 |
| 93 | + with: |
| 94 | + name: dist |
| 95 | + path: dist |
| 96 | + |
| 97 | + publish-nightly: |
| 98 | + runs-on: ubuntu-latest |
| 99 | + needs: notarize-macos |
| 100 | + |
| 101 | + steps: |
| 102 | + - name: Checkout |
| 103 | + uses: actions/checkout@v2 |
| 104 | + |
| 105 | + - name: Download artifact |
| 106 | + uses: actions/download-artifact@v2 |
| 107 | + with: |
| 108 | + name: dist |
| 109 | + # to ensure compatibility with v1 |
| 110 | + path: dist |
| 111 | + |
| 112 | + - name: Upload release files on Arduino downloads servers |
| 113 | + uses: docker://plugins/s3 |
| 114 | + env: |
| 115 | + PLUGIN_SOURCE: "dist/*" |
| 116 | + PLUGIN_TARGET: "/arduino-lint/nightly" |
| 117 | + PLUGIN_STRIP_PREFIX: "dist/" |
| 118 | + PLUGIN_BUCKET: ${{ secrets.DOWNLOADS_BUCKET }} |
| 119 | + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 120 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 121 | + |
| 122 | + - name: Report failure |
| 123 | + if: failure() |
| 124 | + uses: masci/datadog@v1 |
| 125 | + with: |
| 126 | + api-key: ${{ secrets.DD_API_KEY }} |
| 127 | + events: | |
| 128 | + - title: "arduino-lint nightly build failed" |
| 129 | + text: "Nightly build workflow has failed" |
| 130 | + alert_type: "error" |
| 131 | + host: ${{ github.repository }} |
| 132 | + tags: |
| 133 | + - "project:arduino-lint" |
| 134 | + - "workflow:${{ github.workflow }}" |
0 commit comments