|
| 1 | +name: release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "[0-9]+.[0-9]+.[0-9]+*" |
| 7 | + |
| 8 | +jobs: |
| 9 | + create-release-artifacts: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + container: |
| 13 | + image: arduino/arduino-cli:builder-1 |
| 14 | + volumes: |
| 15 | + # cache go dependencies across pipeline's steps |
| 16 | + - ${{ github.workspace }}/go:/go |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v1 |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - name: Build |
| 25 | + run: goreleaser |
| 26 | + |
| 27 | + - name: Upload artifacts |
| 28 | + uses: actions/upload-artifact@v2 |
| 29 | + with: |
| 30 | + name: dist |
| 31 | + path: dist |
| 32 | + |
| 33 | + notarize-macos: |
| 34 | + runs-on: macos-latest |
| 35 | + needs: create-release-artifacts |
| 36 | + |
| 37 | + steps: |
| 38 | + - name: Checkout |
| 39 | + uses: actions/checkout@v2 |
| 40 | + |
| 41 | + - name: Download artifacts |
| 42 | + uses: actions/download-artifact@v2 |
| 43 | + with: |
| 44 | + name: dist |
| 45 | + # to ensure compatibility with v1 |
| 46 | + path: dist |
| 47 | + |
| 48 | + - name: Import Code-Signing Certificates |
| 49 | + env: |
| 50 | + KEYCHAIN: "sign.keychain" |
| 51 | + INSTALLER_CERT_MAC_PATH: "/tmp/ArduinoCerts2020.p12" |
| 52 | + KEYCHAIN_PASSWORD: keychainpassword # Arbitrary password for a keychain that exists only for the duration of the job, so not secret |
| 53 | + run: | |
| 54 | + echo "${{ secrets.INSTALLER_CERT_MAC_P12 }}" | base64 --decode > ${{ env.INSTALLER_CERT_MAC_PATH }} |
| 55 | + security create-keychain -p ${{ env.KEYCHAIN_PASSWORD }} ${{ env.KEYCHAIN }} |
| 56 | + security default-keychain -s ${{ env.KEYCHAIN }} |
| 57 | + security unlock-keychain -p ${{ env.KEYCHAIN_PASSWORD }} ${{ env.KEYCHAIN }} |
| 58 | + security import ${{ env.INSTALLER_CERT_MAC_PATH }} -k ${{ env.KEYCHAIN }} -f pkcs12 -A -T /usr/bin/codesign -P ${{ secrets.INSTALLER_CERT_MAC_PASSWORD }} |
| 59 | + security set-key-partition-list -S apple-tool:,apple: -s -k ${{ env.KEYCHAIN_PASSWORD }} ${{ env.KEYCHAIN }} |
| 60 | +
|
| 61 | + - name: Install gon for code signing and app notarization |
| 62 | + run: | |
| 63 | + wget -q https://github.com/mitchellh/gon/releases/download/v0.2.3/gon_macos.zip |
| 64 | + unzip gon_macos.zip -d /usr/local/bin |
| 65 | +
|
| 66 | + - name: Sign and notarize binary |
| 67 | + env: |
| 68 | + AC_USERNAME: ${{ secrets.AC_USERNAME }} |
| 69 | + AC_PASSWORD: ${{ secrets.AC_PASSWORD }} |
| 70 | + run: | |
| 71 | + gon gon.config.hcl |
| 72 | +
|
| 73 | + - name: Re-package binary and update checksum |
| 74 | + # This step performs the following: |
| 75 | + # 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file) |
| 76 | + # 2. Recalculate package checksum and replace it in the goreleaser nnnnnn-checksums.txt file |
| 77 | + run: | |
| 78 | + # GitHub's upload/download-artifact@v2 action doen't preserve file permissions, |
| 79 | + # so we need to add execution permission back until the action is made to do this. |
| 80 | + chmod +x dist/arduino_lint_osx_darwin_amd64/arduino-lint |
| 81 | + TAG=${GITHUB_REF/refs\/tags\//} |
| 82 | + tar -czvf dist/arduino-lint_${TAG}_macOS_64bit.tar.gz \ |
| 83 | + -C dist/arduino_lint_osx_darwin_amd64/ arduino-lint \ |
| 84 | + -C ../../ LICENSE.txt |
| 85 | + LINT_CHECKSUM=$(shasum -a 256 dist/arduino-lint_${TAG}_macOS_64bit.tar.gz | cut -d " " -f 1) |
| 86 | + perl -pi -w -e "s/.*arduino-lint_${TAG}_macOS_64bit.tar.gz/${LINT_CHECKSUM} arduino-lint_${TAG}_macOS_64bit.tar.gz/g;" dist/*-checksums.txt |
| 87 | +
|
| 88 | + - name: Upload artifacts |
| 89 | + uses: actions/upload-artifact@v2 |
| 90 | + with: |
| 91 | + name: dist |
| 92 | + path: dist |
| 93 | + |
| 94 | + create-release: |
| 95 | + runs-on: ubuntu-latest |
| 96 | + needs: notarize-macos |
| 97 | + |
| 98 | + steps: |
| 99 | + - name: Checkout |
| 100 | + uses: actions/checkout@v2 |
| 101 | + |
| 102 | + - name: Download artifact |
| 103 | + uses: actions/download-artifact@v2 |
| 104 | + with: |
| 105 | + name: dist |
| 106 | + # to ensure compatibility with v1 |
| 107 | + path: dist |
| 108 | + |
| 109 | + - name: Read CHANGELOG |
| 110 | + id: changelog |
| 111 | + run: | |
| 112 | + body=$(cat dist/CHANGELOG.md) |
| 113 | + body="${body//'%'/'%25'}" |
| 114 | + body="${body//$'\n'/'%0A'}" |
| 115 | + body="${body//$'\r'/'%0D'}" |
| 116 | + echo $body |
| 117 | + echo "::set-output name=BODY::$body" |
| 118 | +
|
| 119 | + - name: Identify Prerelease |
| 120 | + # This is a workaround while waiting for create-release action |
| 121 | + # to implement auto pre-release based on tag |
| 122 | + id: prerelease |
| 123 | + run: | |
| 124 | + wget -q -P /tmp https://github.com/fsaintjacques/semver-tool/archive/3.0.0.zip |
| 125 | + unzip -p /tmp/3.0.0.zip semver-tool-3.0.0/src/semver >/tmp/semver && chmod +x /tmp/semver |
| 126 | + if [[ $(/tmp/semver get prerel ${GITHUB_REF/refs\/tags\//}) ]]; then echo "::set-output name=IS_PRE::true"; fi |
| 127 | +
|
| 128 | + - name: Create Github Release |
| 129 | + id: create_release |
| 130 | + uses: actions/create-release@v1 |
| 131 | + env: |
| 132 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 133 | + with: |
| 134 | + tag_name: ${{ github.ref }} |
| 135 | + release_name: ${{ github.ref }} |
| 136 | + body: ${{ steps.changelog.outputs.BODY }} |
| 137 | + draft: false |
| 138 | + prerelease: ${{ steps.prerelease.outputs.IS_PRE }} |
| 139 | + |
| 140 | + - name: Upload release files on Github |
| 141 | + uses: svenstaro/upload-release-action@v2 |
| 142 | + with: |
| 143 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 144 | + file: dist/* |
| 145 | + tag: ${{ github.ref }} |
| 146 | + file_glob: true |
| 147 | + |
| 148 | + - name: Upload release files on Arduino downloads servers |
| 149 | + uses: docker://plugins/s3 |
| 150 | + env: |
| 151 | + PLUGIN_SOURCE: "dist/*" |
| 152 | + PLUGIN_TARGET: "/arduino-lint/" |
| 153 | + PLUGIN_STRIP_PREFIX: "dist/" |
| 154 | + PLUGIN_BUCKET: ${{ secrets.DOWNLOADS_BUCKET }} |
| 155 | + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 156 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
0 commit comments