From 17610af74e675b9f3f47df01461a6a29dc5ed02d Mon Sep 17 00:00:00 2001 From: Jonathan Yu Date: Mon, 23 Aug 2021 01:01:19 +0000 Subject: [PATCH 1/3] chore: update build settings for coder-cli * Update actions/checkout from v1 to @v2 * Configure build to run on pushes/pull requests on main * Add restrictive workflow permissions * Update minimum setup-go from 1.16.3 to 1.16.7 * Enable workflow dispatch for all builds --- .github/workflows/build.yaml | 41 ++++++++++++++++++++++++++---- .github/workflows/integration.yaml | 31 +++++++++++++++++++--- .github/workflows/release.yaml | 36 +++++++++++++++++++++++--- .github/workflows/test.yaml | 24 ++++++++++++++++- 4 files changed, 120 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a0d76acf..8213feaa 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,44 +1,75 @@ name: build -on: [push] + +on: + push: + branches: + - main + + pull_request: + branches: + - main + + workflow_dispatch: + +permissions: + actions: none + checks: none + contents: read + deployments: none + issues: none + packages: none + pull-requests: none + repository-projects: none + security-events: none + statuses: none jobs: build: runs-on: ubuntu-20.04 steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v2 + - uses: actions/setup-go@v2 with: - go-version: '^1.16.3' + go-version: '^1.16.7' + - name: Build run: make -j build/linux build/windows + - name: Upload uses: actions/upload-artifact@v2 with: name: coder-cli path: ./ci/bin/coder-cli-* + build_darwin: runs-on: macos-latest steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v2 + - uses: actions/setup-go@v2 with: - go-version: '^1.16.3' + go-version: '^1.16.7' + - name: Install Gon run: | brew tap mitchellh/gon brew install mitchellh/gon/gon + - name: Import Signing Certificates uses: Apple-Actions/import-codesign-certs@v1 with: p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }} p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }} + - name: Build run: make build/macos env: AC_USERNAME: ${{ secrets.AC_USERNAME }} AC_PASSWORD: ${{ secrets.AC_PASSWORD }} + - name: Upload uses: actions/upload-artifact@v2 with: diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index e7abedaa..9e4e1046 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -1,8 +1,30 @@ name: integration + on: push: + branches: + - main + + pull_request: + branches: + - main + schedule: - - cron: '*/180 * * * *' + - cron: '*/180 * * * *' + + workflow_dispatch: + +permissions: + actions: none + checks: none + contents: read + deployments: none + issues: none + packages: none + pull-requests: none + repository-projects: none + security-events: none + statuses: none jobs: integration: @@ -12,15 +34,18 @@ jobs: CODER_EMAIL: ${{ secrets.CODER_EMAIL }} CODER_PASSWORD: ${{ secrets.CODER_PASSWORD }} steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 + - uses: actions/cache@v2 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go- + - uses: actions/setup-go@v2 with: - go-version: '^1.14' + go-version: '^1.16.7' + - name: integration tests run: ./ci/scripts/integration.sh diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 4a0606fb..e5cd15a2 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,7 +1,21 @@ +name: create_github_release + on: create: tags: "v*" -name: create_github_release + +permissions: + actions: none + checks: none + contents: read + deployments: none + issues: none + packages: none + pull-requests: none + repository-projects: none + security-events: none + statuses: none + jobs: build: name: Build binaries @@ -9,49 +23,60 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 + - uses: actions/setup-go@v2 with: - go-version: '^1.16.3' + go-version: '^1.16.7' + - name: Build run: make -j build/linux build/windows + - name: Upload linux uses: actions/upload-artifact@v2 with: name: coder-cli-linux-amd64 path: ./ci/bin/coder-cli-linux-amd64.tar.gz + - name: Upload windows uses: actions/upload-artifact@v2 with: name: coder-cli-windows path: ./ci/bin/coder-cli-windows.zip + build_darwin: name: Build darwin binary runs-on: macos-latest steps: - name: Checkout code uses: actions/checkout@v2 + - name: Install Gon run: | brew tap mitchellh/gon brew install mitchellh/gon/gon + - name: Import Signing Certificates uses: Apple-Actions/import-codesign-certs@v1 with: p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }} p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }} + - uses: actions/setup-go@v2 with: - go-version: '^1.16.3' + go-version: '^1.16.7' + - name: Build Release Assets run: make build/macos env: AC_USERNAME: ${{ secrets.AC_USERNAME }} AC_PASSWORD: ${{ secrets.AC_PASSWORD }} + - name: Upload darwin uses: actions/upload-artifact@v2 with: name: coder-cli-darwin-amd64 path: ./ci/bin/coder-cli-darwin-amd64.zip + draft_release: name: Create Release runs-on: ubuntu-20.04 @@ -60,8 +85,10 @@ jobs: - build steps: - uses: actions/download-artifact@v2 + - name: content run: sh -c "ls -al" + - name: Create Release id: create_release uses: actions/create-release@v1 @@ -73,6 +100,7 @@ jobs: body: "" draft: true prerelease: false + - name: Upload Linux Release id: upload-linux-release-asset uses: actions/upload-release-asset@v1 @@ -83,6 +111,7 @@ jobs: asset_path: coder-cli-linux-amd64/coder-cli-linux-amd64.tar.gz asset_name: coder-cli-linux-amd64.tar.gz asset_content_type: application/tar+gzip + - name: Upload MacOS Release id: upload-macos-release-asset uses: actions/upload-release-asset@v1 @@ -93,6 +122,7 @@ jobs: asset_path: coder-cli-darwin-amd64/coder-cli-darwin-amd64.zip asset_name: coder-cli-darwin-amd64.zip asset_content_type: application/zip + - name: Upload Windows Release id: upload-windows-release-asset uses: actions/upload-release-asset@v1 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 79a324a9..513a3142 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,5 +1,27 @@ name: test -on: [push] + +on: + push: + branches: + - main + + pull_request: + branches: + - main + + workflow_dispatch: + +permissions: + actions: none + checks: none + contents: read + deployments: none + issues: none + packages: none + pull-requests: none + repository-projects: none + security-events: none + statuses: none jobs: fmt: From bbad4db9d3e5a0626919ccabe570bb10cc4c4dbc Mon Sep 17 00:00:00 2001 From: Jonathan Yu Date: Mon, 23 Aug 2021 01:17:29 +0000 Subject: [PATCH 2/3] use checkout-depth of 0 to fetch tags --- .github/workflows/build.yaml | 4 ++++ .github/workflows/release.yaml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 8213feaa..33c5b836 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -29,6 +29,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - uses: actions/setup-go@v2 with: @@ -48,6 +50,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - uses: actions/setup-go@v2 with: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index e5cd15a2..d3163c92 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -23,6 +23,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 + with: + fetch-depth: 0 - uses: actions/setup-go@v2 with: @@ -49,6 +51,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Install Gon run: | From 3e21daf338617dd881e7076c50c138879b55a4d0 Mon Sep 17 00:00:00 2001 From: Jonathan Yu Date: Mon, 23 Aug 2021 01:21:00 +0000 Subject: [PATCH 3/3] wip --- .github/workflows/integration.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 9e4e1046..bb1a39d4 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -35,6 +35,8 @@ jobs: CODER_PASSWORD: ${{ secrets.CODER_PASSWORD }} steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - uses: actions/cache@v2 with: