|
| 1 | +# GitHub release workflow. |
| 2 | +name: TestRelease |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + |
| 6 | +permissions: |
| 7 | + # Required to publish a release |
| 8 | + contents: write |
| 9 | + # Necessary to push docker images to ghcr.io. |
| 10 | + packages: write |
| 11 | + # Necessary for GCP authentication (https://github.com/google-github-actions/setup-gcloud#usage) |
| 12 | + id-token: write |
| 13 | + |
| 14 | +concurrency: ${{ github.workflow }}-${{ github.ref }} |
| 15 | + |
| 16 | +jobs: |
| 17 | + release: |
| 18 | + name: Build and publish |
| 19 | + runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }} |
| 20 | + env: |
| 21 | + # Necessary for Docker manifest |
| 22 | + DOCKER_CLI_EXPERIMENTAL: "enabled" |
| 23 | + outputs: |
| 24 | + version: ${{ steps.version.outputs.version }} |
| 25 | + steps: |
| 26 | + - name: Authenticate to Google Cloud |
| 27 | + uses: google-github-actions/auth@v2 |
| 28 | + with: |
| 29 | + workload_identity_provider: ${{ secrets.GCP_WORKLOAD_ID_PROVIDER }} |
| 30 | + service_account: ${{ secrets.GCP_CODE_SIGNING_SERVICE_ACCOUNT }} |
| 31 | + |
| 32 | + - name: Setup GCloud SDK |
| 33 | + uses: "google-github-actions/setup-gcloud@v2" |
| 34 | + |
| 35 | + - name: Checkout |
| 36 | + uses: actions/checkout@v4 |
| 37 | + with: |
| 38 | + fetch-depth: 0 |
| 39 | + |
| 40 | + # If the event that triggered the build was an annotated tag (which our |
| 41 | + # tags are supposed to be), actions/checkout has a bug where the tag in |
| 42 | + # question is only a lightweight tag and not a full annotated tag. This |
| 43 | + # command seems to fix it. |
| 44 | + # https://github.com/actions/checkout/issues/290 |
| 45 | + - name: Fetch git tags |
| 46 | + run: git fetch --tags --force |
| 47 | + |
| 48 | + - name: Print version |
| 49 | + id: version |
| 50 | + run: | |
| 51 | + set -euo pipefail |
| 52 | + version="0.0.1-rc.1" |
| 53 | + echo "version=$version" >> $GITHUB_OUTPUT |
| 54 | + # Speed up future version.sh calls. |
| 55 | + echo "CODER_FORCE_VERSION=$version" >> $GITHUB_ENV |
| 56 | + echo "$version" |
| 57 | +
|
| 58 | + - name: Docker Login |
| 59 | + uses: docker/login-action@v3 |
| 60 | + with: |
| 61 | + registry: ghcr.io |
| 62 | + username: ${{ github.actor }} |
| 63 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 64 | + |
| 65 | + - name: Setup Go |
| 66 | + uses: ./.github/actions/setup-go |
| 67 | + |
| 68 | + - name: Setup Node |
| 69 | + uses: ./.github/actions/setup-node |
| 70 | + |
| 71 | + - name: Setup Java |
| 72 | + uses: sudo apt-get install -y default-jre |
| 73 | + |
| 74 | + - name: Install nsis and zstd |
| 75 | + run: sudo apt-get install -y nsis zstd |
| 76 | + |
| 77 | + - name: Install nfpm |
| 78 | + run: | |
| 79 | + set -euo pipefail |
| 80 | + wget -O /tmp/nfpm.deb https://github.com/goreleaser/nfpm/releases/download/v2.35.1/nfpm_2.35.1_amd64.deb |
| 81 | + sudo dpkg -i /tmp/nfpm.deb |
| 82 | + rm /tmp/nfpm.deb |
| 83 | +
|
| 84 | + - name: Install rcodesign |
| 85 | + run: | |
| 86 | + set -euo pipefail |
| 87 | + wget -O /tmp/rcodesign.tar.gz https://github.com/indygreg/apple-platform-rs/releases/download/apple-codesign%2F0.22.0/apple-codesign-0.22.0-x86_64-unknown-linux-musl.tar.gz |
| 88 | + sudo tar -xzf /tmp/rcodesign.tar.gz \ |
| 89 | + -C /usr/bin \ |
| 90 | + --strip-components=1 \ |
| 91 | + apple-codesign-0.22.0-x86_64-unknown-linux-musl/rcodesign |
| 92 | + rm /tmp/rcodesign.tar.gz |
| 93 | +
|
| 94 | + - name: Setup Apple Developer certificate and API key |
| 95 | + run: | |
| 96 | + set -euo pipefail |
| 97 | + touch /tmp/{apple_cert.p12,apple_cert_password.txt,apple_apikey.p8} |
| 98 | + chmod 600 /tmp/{apple_cert.p12,apple_cert_password.txt,apple_apikey.p8} |
| 99 | + echo "$AC_CERTIFICATE_P12_BASE64" | base64 -d > /tmp/apple_cert.p12 |
| 100 | + echo "$AC_CERTIFICATE_PASSWORD" > /tmp/apple_cert_password.txt |
| 101 | + echo "$AC_APIKEY_P8_BASE64" | base64 -d > /tmp/apple_apikey.p8 |
| 102 | + env: |
| 103 | + AC_CERTIFICATE_P12_BASE64: ${{ secrets.AC_CERTIFICATE_P12_BASE64 }} |
| 104 | + AC_CERTIFICATE_PASSWORD: ${{ secrets.AC_CERTIFICATE_PASSWORD }} |
| 105 | + AC_APIKEY_P8_BASE64: ${{ secrets.AC_APIKEY_P8_BASE64 }} |
| 106 | + |
| 107 | + - name: Setup Windows EV Signing Certificate |
| 108 | + run: | |
| 109 | + set -euo pipefail |
| 110 | + touch /tmp/ev_cert.pem |
| 111 | + chmod 600 /tmp/ev_cert.pem |
| 112 | + echo "$EV_SIGNING_CERT" > /tmp/ev_cert.pem |
| 113 | + wget https://github.com/ebourg/jsign/releases/download/6.0/jsign-6.0.jar -o /tmp/jsign-6.0.jar |
| 114 | + env: |
| 115 | + EV_SIGNING_CERT: ${{ secrets.EV_SIGNING_CERT }} |
| 116 | + |
| 117 | + - name: Build binaries |
| 118 | + run: | |
| 119 | + set -euo pipefail |
| 120 | + go mod download |
| 121 | +
|
| 122 | + version="$(./scripts/version.sh)" |
| 123 | + make gen/mark-fresh |
| 124 | + make -j \ |
| 125 | + build/coder_"$version"_linux_{amd64,armv7,arm64}.{tar.gz,apk,deb,rpm} \ |
| 126 | + build/coder_"$version"_{darwin,windows}_{amd64,arm64}.zip \ |
| 127 | + build/coder_"$version"_windows_amd64_installer.exe \ |
| 128 | + build/coder_helm_"$version".tgz \ |
| 129 | + build/provisioner_helm_"$version".tgz |
| 130 | + env: |
| 131 | + CODER_SIGN_WINDOWS: "1" |
| 132 | + CODER_SIGN_DARWIN: "1" |
| 133 | + AC_CERTIFICATE_FILE: /tmp/apple_cert.p12 |
| 134 | + AC_CERTIFICATE_PASSWORD_FILE: /tmp/apple_cert_password.txt |
| 135 | + AC_APIKEY_ISSUER_ID: ${{ secrets.AC_APIKEY_ISSUER_ID }} |
| 136 | + AC_APIKEY_ID: ${{ secrets.AC_APIKEY_ID }} |
| 137 | + AC_APIKEY_FILE: /tmp/apple_apikey.p8 |
| 138 | + EV_KEY: ${{ secrets.EV_KEY }} |
| 139 | + EV_KEYSTORE: ${{ secrets.EV_KEYSTORE }} |
| 140 | + EV_TSA_URL: ${{ secrets.EV_TSA_URL }} |
| 141 | + EV_CERTIFICATE_PATH: /tmp/ev_cert.pem |
| 142 | + JSIGN_PATH: /tmp/jsign-6.0.jar |
| 143 | + |
| 144 | + - name: Delete Apple Developer certificate and API key |
| 145 | + run: rm -f /tmp/{apple_cert.p12,apple_cert_password.txt,apple_apikey.p8} |
| 146 | + |
| 147 | + - name: Delete Windows EV Signing Cert |
| 148 | + run: rm /tmp/ev_cert.pem |
| 149 | + |
| 150 | + - name: Upload artifacts to actions (if dry-run) |
| 151 | + uses: actions/upload-artifact@v4 |
| 152 | + with: |
| 153 | + name: release-artifacts |
| 154 | + path: | |
| 155 | + ./build/*_installer.exe |
| 156 | + ./build/*.zip |
| 157 | + ./build/*.tar.gz |
| 158 | + ./build/*.tgz |
| 159 | + ./build/*.apk |
| 160 | + ./build/*.deb |
| 161 | + ./build/*.rpm |
| 162 | + retention-days: 1 |
0 commit comments