From 3a99766c53d3a9778b67552861df8cc4fc094987 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 6 Aug 2024 17:58:32 +0300 Subject: [PATCH] ci: create build pipeline for snapcraft (#160) --- .github/workflows/publish-snaps.yaml | 64 ++++++++++++++++++++++++++++ .gitignore | 2 + README.md | 5 +-- snap/snapcraft.yaml | 4 +- 4 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/publish-snaps.yaml diff --git a/.github/workflows/publish-snaps.yaml b/.github/workflows/publish-snaps.yaml new file mode 100644 index 0000000..4b368fd --- /dev/null +++ b/.github/workflows/publish-snaps.yaml @@ -0,0 +1,64 @@ +name: publish-snaps + +on: + workflow_dispatch: + inputs: + coder_version: + description: "Coder version" + required: true + release_channel: + description: "Release channel" + required: true + type: choice + options: + - stable + - mainline + repository_dispatch: + types: [coder-release] + +jobs: + build-and-publish: + runs-on: ${{ matrix.os }} + env: + SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }} + name: publish-snaps + strategy: + matrix: + os: + - depot-ubuntu-22.04 + - depot-ubuntu-22.04-arm + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Set metadata + id: metadata + run: | + if [[ "${{ github.event_name }}" == "repository_dispatch" ]]; then + echo "coder_version=${{ github.event.client_payload.coder_version }}" >> "$GITHUB_OUTPUT" + echo "release_channel=${{ github.event.client_payload.release_channel }}" >> "$GITHUB_OUTPUT" + elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then + echo "coder_version=${{ github.event.inputs.coder_version }}" >> "$GITHUB_OUTPUT" + echo "release_channel=${{ github.event.inputs.release_channel }}" >> "$GITHUB_OUTPUT" + else + echo "Unknown event: ${{ github.event_name }}" + exit 1 + fi + + - name: Set version in snapcraft.yaml + run: | + sed -i "s/version: \".*\"/version: \"${{ steps.metadata.outputs.coder_version }}\"/" snap/snapcraft.yaml + git diff snap/snapcraft.yaml + + - name: Setup Snapcraft + uses: samuelmeuli/action-snapcraft@v2 + + - name: Build and publish snaps + run: | + snapcraft build + if [[ ${{ steps.metadata.outputs.release_channel }} == "stable" ]]; then + snapcraft upload --release=latest/stable *.snap + else + snapcraft upload --release=latest/candidate,latest/beta,latest/edge *.snap + fi diff --git a/.gitignore b/.gitignore index 533315e..b50d0c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .env packer-manifest.json +# built snaps +*.snap diff --git a/README.md b/README.md index 48396af..59e35fa 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,4 @@ Install [Coder](https://github.com/coder/coder) to your preferred cloud with a p | Render.com Logo | Render | Live ✅ | [Docs: Deploy Coder on Render](./render/README.md) | [![Deploy to Render](https://render.com/images/deploy-to-render-button.svg)](https://render.com/deploy?repo=https://github.com/coder/packages) | | AWS EKS Logo | AWS EKS | In progress | [Docs: Coder on Kubernetes](https://coder.com/docs/v2/latest/install/kubernetes) | [Deploy from AWS Marketplace](https://example.com) | | Google Compute Engine logo | Google Compute Engine | Live ✅ | [Guide: Google Compute Engine](https://coder.com/docs/v2/latest/platforms/gcp) | [Deploy from GCP Marketplace](https://console.cloud.google.com/marketplace/product/coder-enterprise-market-public/coder-v2) | -| Snapcraft Logo | Snapcraft | Live ✅ | [Install Coder from Snapcraft](https://snapcraft.io/coder) | - -[![Get it from the Snap Store](https://snapcraft.io/static/images/badges/en/snap-store-white.svg)](https://snapcraft.io/coder) - | +| Snapcraft Logo | Snapcraft | Live ✅ | `snap install coder` | [![Get it from the Snap Store](https://snapcraft.io/static/images/badges/en/snap-store-white.svg)](https://snapcraft.io/coder) | diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 24c3cf3..52abd32 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -2,8 +2,8 @@ name: coder title: Coder type: app base: core24 -version: '2.12.4' -summary: Self-Hosted Cloud Development Environments +version: "2.13.1" # version is managed in .github/workflows/publish-snaps.yaml +summary: Self-Hosted Cloud Development Environments license: AGPL-3.0 contact: https://coder.com/contact issues: https://github.com/coder/coder/issues