|
| 1 | +name: Package and Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - 'preview/**' |
| 8 | + tags: |
| 9 | + - test* |
| 10 | + - v* |
| 11 | + |
| 12 | +jobs: |
| 13 | + package-x64: |
| 14 | + runs-on: ubuntu18.04 |
| 15 | + env: |
| 16 | + TERM: xterm |
| 17 | + strategy: |
| 18 | + node-version: |
| 19 | + - '14' |
| 20 | + |
| 21 | + steps: |
| 22 | + # Install deps and cache |
| 23 | + # Eventually it would be great if these steps could live in a separate YAML file |
| 24 | + # that could be included in line to avoid code duplication |
| 25 | + - name: Checkout code |
| 26 | + uses: actions/checkout@v2 |
| 27 | + with: |
| 28 | + fetch-depth: 0 |
| 29 | + - name: Install node ${{ matrix.node-version }} |
| 30 | + uses: actions/setup-node@v2 |
| 31 | + with: |
| 32 | + node-version: ${{ matrix.node-version }} |
| 33 | + - name: Get Yarn cache directory |
| 34 | + id: yarn-cache-dir-path |
| 35 | + run: echo "::set-output name=dir::$(yarn cache dir)" |
| 36 | + - name: Use Yarn cache |
| 37 | + id: yarn-cache |
| 38 | + uses: actions/cache@v2 |
| 39 | + with: |
| 40 | + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} |
| 41 | + key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }} |
| 42 | + - name: Install Yarn dependencies |
| 43 | + run: yarn install --prefer-offline --frozen-lockfile |
| 44 | + |
| 45 | + # Package and upload the cli |
| 46 | + # @NOTE: We cross-compile on Linux because _right now_ this seems to be |
| 47 | + # the only place we can reliably build all the variants. We use actions/upload |
| 48 | + # so move assets between jobs |
| 49 | + - name: Package ${{ matrix.variant }} CLI |
| 50 | + run: | |
| 51 | + node ./scripts/dev-version.js |
| 52 | + node ./bin/lando.js version |
| 53 | + yarn pkg --target=node${{ matrix.node-version }}-${{ matrix.variant }} --no-version |
| 54 | + - name: Upload lando-build-${{ matrix.variant }}-${{ github.sha }} |
| 55 | + uses: actions/upload-artifact@v2 |
| 56 | + with: |
| 57 | + name: lando-build-${{ matrix.variant }}-${{ github.sha }} |
| 58 | + path: dist/ |
| 59 | + if-no-files-found: error |
| 60 | + retention-days: 1 |
| 61 | + |
| 62 | + package-arm64: |
| 63 | + runs-on: ${{ matrix.os }} |
| 64 | + env: |
| 65 | + TERM: xterm |
| 66 | + strategy: |
| 67 | + matrix: |
| 68 | + os: |
| 69 | + - ubuntu-20.04 |
| 70 | + node-version: |
| 71 | + - '14' |
| 72 | + |
| 73 | + steps: |
| 74 | + # Install deps and cache |
| 75 | + # Eventually it would be great if these steps could live in a separate YAML file |
| 76 | + # that could be included in line to avoid code duplication |
| 77 | + - name: Checkout code |
| 78 | + uses: actions/checkout@v2 |
| 79 | + with: |
| 80 | + fetch-depth: 0 |
| 81 | + - name: Install node ${{ matrix.node-version }} |
| 82 | + uses: actions/setup-node@v2 |
| 83 | + with: |
| 84 | + node-version: ${{ matrix.node-version }} |
| 85 | + - name: Get Yarn cache directory |
| 86 | + id: yarn-cache-dir-path |
| 87 | + run: echo "::set-output name=dir::$(yarn cache dir)" |
| 88 | + - name: Use Yarn cache |
| 89 | + id: yarn-cache |
| 90 | + uses: actions/cache@v2 |
| 91 | + with: |
| 92 | + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} |
| 93 | + key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }} |
| 94 | + - name: Install Yarn dependencies |
| 95 | + run: yarn install --prefer-offline --frozen-lockfile |
| 96 | + |
| 97 | + # Package and upload the cli |
| 98 | + # @NOTE: We cross-compile on Linux because _right now_ this seems to be |
| 99 | + # the only place we can reliably build all the variants. We use actions/upload |
| 100 | + # so move assets between jobs |
| 101 | + - name: Package ${{ matrix.variant }} CLI |
| 102 | + run: | |
| 103 | + node ./scripts/dev-version.js |
| 104 | + node ./bin/lando.js version |
| 105 | + yarn pkg --target=node${{ matrix.node-version }}-${{ matrix.variant }} --no-version |
| 106 | + - name: Upload lando-build-${{ matrix.variant }}-${{ github.sha }} |
| 107 | + uses: actions/upload-artifact@v2 |
| 108 | + with: |
| 109 | + name: lando-build-${{ matrix.variant }}-${{ github.sha }} |
| 110 | + path: dist/ |
| 111 | + if-no-files-found: error |
| 112 | + retention-days: 1 |
| 113 | + |
| 114 | + |
| 115 | + ship-x64: |
| 116 | + runs-on: ${{ matrix.os }} |
| 117 | + needs: |
| 118 | + - package-x64 |
| 119 | + env: |
| 120 | + TERM: xterm |
| 121 | + strategy: |
| 122 | + matrix: |
| 123 | + os: |
| 124 | + - macos-10.15 |
| 125 | + - ubuntu-20.04 |
| 126 | + - windows-2019 |
| 127 | + arch: |
| 128 | + - x64 |
| 129 | + - arm64 |
| 130 | + exclude: |
| 131 | + - os: windows-2019 |
| 132 | + arch: arm64 |
| 133 | + steps: |
| 134 | + # Set things up for signing, notarizing, uploading etc |
| 135 | + - name: Checkout code |
| 136 | + uses: actions/checkout@v2 |
| 137 | + with: |
| 138 | + fetch-depth: 0 |
| 139 | + - name: Set other variables |
| 140 | + id: vars |
| 141 | + shell: bash |
| 142 | + run: | |
| 143 | + # Set generic source ref vars |
| 144 | + echo "::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/}" |
| 145 | + echo "::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/}" |
| 146 | + echo "::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}" |
| 147 | + # Unset vars if it makes sense to do so |
| 148 | + if [ "$GITHUB_REF" == "${GITHUB_REF#refs/tags/}" ]; then echo "::set-output name=SOURCE_TAG::"; fi |
| 149 | + if [ "$GITHUB_REF" == "${GITHUB_REF#refs/heads/}" ]; then echo "::set-output name=SOURCE_BRANCH::"; fi |
| 150 | +
|
| 151 | + # Set os specific vars |
| 152 | + if [ "$RUNNER_OS" == "Linux" ]; then |
| 153 | + echo '::set-output name=OS::linux' |
| 154 | + echo '::set-output name=PKG_ENDING::' |
| 155 | + elif [ "$RUNNER_OS" == "Windows" ]; then |
| 156 | + echo '::set-output name=OS::win' |
| 157 | + echo '::set-output name=PKG_ENDING::.exe' |
| 158 | + else |
| 159 | + echo '::set-output name=OS::macos' |
| 160 | + echo '::set-output name=PKG_ENDING::' |
| 161 | + fi |
| 162 | + - name: Set SOURCE_PKG |
| 163 | + id: pkg |
| 164 | + shell: bash |
| 165 | + run: echo '::set-output name=SOURCE_PKG::lando-${{ steps.vars.outputs.OS }}-${{ matrix.arch }}${{ steps.vars.outputs.PKG_ENDING }}' |
| 166 | + - name: Test user defined variables |
| 167 | + shell: bash |
| 168 | + run: | |
| 169 | + echo "The OS is ${{ steps.vars.outputs.OS }}" |
| 170 | + echo "The SOURCE_NAME is ${{ steps.vars.outputs.SOURCE_NAME }}" |
| 171 | + echo "The SOURCE_BRANCH is ${{ steps.vars.outputs.SOURCE_BRANCH }}" |
| 172 | + echo "The SOURCE_TAG is ${{ steps.vars.outputs.SOURCE_TAG }}" |
| 173 | + echo "The SOURCE_PKG is ${{ steps.pkg.outputs.SOURCE_PKG }}" |
| 174 | + - name: Download lando-build-${{ steps.vars.outputs.OS }}-${{ matrix.arch }}-${{ github.sha }} |
| 175 | + uses: actions/download-artifact@v2 |
| 176 | + with: |
| 177 | + name: lando-build-${{ steps.vars.outputs.OS }}-${{ matrix.arch }}-${{ github.sha }} |
| 178 | + path: dist |
| 179 | + |
| 180 | + # Codesign macOS binaries |
| 181 | + # NOTE: We cannot currently do this on macOS because of below issue |
| 182 | + # https://github.com/vercel/pkg/issues/128 |
| 183 | + # However, the logic is here and ready to go once that is resolved |
| 184 | + # NOTE: We also should add notarization logic here? |
| 185 | + - name: Codesign macOS binaries |
| 186 | + env: |
| 187 | + APPLE_CERT_DATA: ${{ secrets.APPLE_CERT_DATA }} |
| 188 | + APPLE_CERT_PASSWORD: ${{ secrets.APPLE_CERT_PASSWORD }} |
| 189 | + APPLE_TEAM_ID: FY8GAUX282 |
| 190 | + if: ${{ steps.vars.outputs.OS == 'macos' }} |
| 191 | + run: | |
| 192 | + ./scripts/sign-macos.sh ./dist/${{ steps.pkg.outputs.SOURCE_PKG }} |
| 193 | + echo "::warning:: Codesign currently disabled because of https://github.com/vercel/pkg/issues/128" |
| 194 | + # Codesign WiNdOzE binaries |
| 195 | + - name: Codesign Windoze binaries |
| 196 | + env: |
| 197 | + WINDOZE_CERT_DATA: ${{ secrets.WINDOZE_CERT_DATA }} |
| 198 | + WINDOZE_CERT_PASSWORD: ${{ secrets.WINDOZE_CERT_PASSWORD }} |
| 199 | + if: ${{ steps.vars.outputs.OS == 'win' }} |
| 200 | + shell: powershell |
| 201 | + run: ./scripts/sign-win.ps1 ./dist/${{ steps.pkg.outputs.SOURCE_PKG }} |
| 202 | + |
| 203 | + # Depending on the type of commit eg tagged, etc create the releases we need |
| 204 | + - name: Create releases |
| 205 | + env: |
| 206 | + SOURCE_BRANCH: ${{ steps.vars.outputs.SOURCE_BRANCH }} |
| 207 | + SOURCE_TAG: ${{ steps.vars.outputs.SOURCE_TAG }} |
| 208 | + PKG_PREFIX: "lando-${{ steps.vars.outputs.OS }}-${{ matrix.arch }}" |
| 209 | + PKG_SUFFIX: ${{ steps.vars.outputs.PKG_ENDING }} |
| 210 | + shell: bash |
| 211 | + run: | |
| 212 | + # Create release directories |
| 213 | + mkdir -p ./releases ./dev-builds |
| 214 | +
|
| 215 | + # Snapshot release |
| 216 | + cp -f ./dist/${{ steps.pkg.outputs.SOURCE_PKG }} "./dev-builds/$PKG_PREFIX-build-${{ github.sha }}$PKG_SUFFIX" |
| 217 | +
|
| 218 | + # Branch releases |
| 219 | + if [ -z "$SOURCE_TAG" ]; then cp -f ./dist/${{ steps.pkg.outputs.SOURCE_PKG }} "./releases/$PKG_PREFIX-$SOURCE_BRANCH-latest$PKG_SUFFIX"; fi |
| 220 | + # Latest dev release |
| 221 | + if [[ "$SOURCE_BRANCH" == "main" ]]; then cp -f ./dist/${{ steps.pkg.outputs.SOURCE_PKG }} "./releases/$PKG_PREFIX-latest$PKG_SUFFIX"; fi |
| 222 | + # Tag releases |
| 223 | + if [ ! -z "$SOURCE_TAG" ]; then cp -f ./dist/${{ steps.pkg.outputs.SOURCE_PKG }} "./releases/$PKG_PREFIX-$SOURCE_TAG$PKG_SUFFIX"; fi |
| 224 | + # Latest stable release |
| 225 | + if [ ! -z "$SOURCE_TAG" ]; then cp -f ./dist/${{ steps.pkg.outputs.SOURCE_PKG }} "./releases/$PKG_PREFIX-stable$PKG_SUFFIX"; fi |
| 226 | +
|
| 227 | + # Print what we end up with |
| 228 | + ls -lsa ./releases |
| 229 | + ls -lsa ./dev-builds |
| 230 | +
|
| 231 | + # Replace previously posted unsigned raw artifacts with signed build snapshots |
| 232 | + - name: Remove unsigned artifacts |
| 233 | + uses: geekyeggo/delete-artifact@v1 |
| 234 | + with: |
| 235 | + name: lando-build-${{ steps.vars.outputs.OS }}-${{ matrix.arch }}-${{ github.sha }} |
| 236 | + - name: Upload build snapshot as Actions artifact |
| 237 | + uses: actions/upload-artifact@v2 |
| 238 | + with: |
| 239 | + name: lando-${{ steps.vars.outputs.OS }}-${{ matrix.arch }}-${{ github.sha }}${{ steps.vars.outputs.PKG_ENDING }} |
| 240 | + path: dev-builds/ |
| 241 | + if-no-files-found: error |
| 242 | + retention-days: 30 |
| 243 | + # Upload releases to S3 |
| 244 | + - name: Configure S3 Credentials |
| 245 | + uses: aws-actions/configure-aws-credentials@v1 |
| 246 | + with: |
| 247 | + aws-access-key-id: ${{ secrets.S3_ACCESS_KEY_ID }} |
| 248 | + aws-secret-access-key: ${{ secrets.S3_SECRET_ACCESS_KEY }} |
| 249 | + aws-region: us-east-1 |
| 250 | + - name: Upload releases to S3 |
| 251 | + shell: bash |
| 252 | + run: | |
| 253 | + aws s3 sync ./releases s3://files.lando.dev/cli --acl public-read |
| 254 | + # Upload releases to GitHub Releases |
| 255 | + - name: Upload releases to GitHub Releases |
| 256 | + uses: softprops/action-gh-release@v1 |
| 257 | + if: startsWith(github.ref, 'refs/tags/') |
| 258 | + env: |
| 259 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 260 | + with: |
| 261 | + draft: true |
| 262 | + files: ./releases/lando-${{ steps.vars.outputs.OS }}-${{ matrix.arch }}-${{ steps.vars.outputs.SOURCE_TAG }}${{ steps.vars.outputs.PKG_ENDING }} |
| 263 | + # @TODO: Handle autochangelog stuff here eventaully |
| 264 | + # body_path: ${{ github.workflow }}-CHANGELOG.txt |
0 commit comments