|
| 1 | +name: Dev Build |
| 2 | + |
| 3 | +concurrency: |
| 4 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 5 | + cancel-in-progress: false |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + - feature/wip |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: write |
| 16 | + packages: write |
| 17 | + pages: write |
| 18 | + id-token: write |
| 19 | + |
| 20 | +env: |
| 21 | + REGISTRY: ghcr.io |
| 22 | + IMAGE_NAME: ${{ github.repository }} |
| 23 | + |
| 24 | +jobs: |
| 25 | + secrets: |
| 26 | + name: Detect Secrets |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v4 |
| 30 | + with: |
| 31 | + fetch-depth: 0 |
| 32 | + - uses: gitleaks/gitleaks-action@v2 |
| 33 | + env: |
| 34 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 35 | + |
| 36 | + docker-build: |
| 37 | + name: Docker Build (${{ matrix.arch }}) |
| 38 | + needs: secrets |
| 39 | + strategy: |
| 40 | + fail-fast: false |
| 41 | + matrix: |
| 42 | + include: |
| 43 | + - runner: ubuntu-latest |
| 44 | + arch: amd64 |
| 45 | + platform: linux/amd64 |
| 46 | + - runner: ubuntu-24.04-arm |
| 47 | + arch: arm64 |
| 48 | + platform: linux/arm64 |
| 49 | + runs-on: ${{ matrix.runner }} |
| 50 | + steps: |
| 51 | + - uses: actions/checkout@v4 |
| 52 | + |
| 53 | + - name: Set lowercase image name |
| 54 | + run: echo "IMAGE_NAME_LC=${IMAGE_NAME,,}" >> $GITHUB_ENV |
| 55 | + |
| 56 | + - name: Free disk space |
| 57 | + run: | |
| 58 | + sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL |
| 59 | + sudo docker image prune -af |
| 60 | + df -h |
| 61 | +
|
| 62 | +
|
| 63 | + - name: Set up Docker Buildx |
| 64 | + uses: docker/setup-buildx-action@v3 |
| 65 | + |
| 66 | + - name: Log in to GitHub Container Registry |
| 67 | + uses: docker/login-action@v3 |
| 68 | + with: |
| 69 | + registry: ${{ env.REGISTRY }} |
| 70 | + username: ${{ github.actor }} |
| 71 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 72 | + |
| 73 | + - name: Build and push ci group |
| 74 | + run: docker buildx bake --push ci |
| 75 | + env: |
| 76 | + VERSION: v0.0.0-${{ matrix.arch }} |
| 77 | + PLATFORMS: ${{ matrix.platform }} |
| 78 | + REGISTRY: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LC }} |
| 79 | + |
| 80 | + docker-test: |
| 81 | + name: Docker Test (${{ matrix.arch }}, ${{ matrix.variant }}) |
| 82 | + needs: docker-build |
| 83 | + strategy: |
| 84 | + fail-fast: false |
| 85 | + matrix: |
| 86 | + include: |
| 87 | + - runner: ubuntu-latest |
| 88 | + arch: amd64 |
| 89 | + variant: nix |
| 90 | + - runner: ubuntu-24.04-arm |
| 91 | + arch: arm64 |
| 92 | + variant: nix |
| 93 | + - runner: ubuntu-latest |
| 94 | + arch: amd64 |
| 95 | + variant: ultimate |
| 96 | + - runner: ubuntu-24.04-arm |
| 97 | + arch: arm64 |
| 98 | + variant: ultimate |
| 99 | + runs-on: ${{ matrix.runner }} |
| 100 | + steps: |
| 101 | + - uses: actions/checkout@v4 |
| 102 | + |
| 103 | + - name: Set lowercase image name |
| 104 | + run: echo "IMAGE_NAME_LC=${IMAGE_NAME,,}" >> $GITHUB_ENV |
| 105 | + |
| 106 | + - name: Log in to GitHub Container Registry |
| 107 | + uses: docker/login-action@v3 |
| 108 | + with: |
| 109 | + registry: ${{ env.REGISTRY }} |
| 110 | + username: ${{ github.actor }} |
| 111 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 112 | + |
| 113 | + - name: Set up Go |
| 114 | + uses: actions/setup-go@v5 |
| 115 | + with: |
| 116 | + go-version-file: go.mod |
| 117 | + cache-dependency-path: go.sum |
| 118 | + |
| 119 | + - name: Run container tests |
| 120 | + env: |
| 121 | + DEVCELL_IMAGE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LC }}:v0.0.0-${{ matrix.arch }}-${{ matrix.variant }} |
| 122 | + MCP_SECRET_TEST_PASSWORD: fake-secret-ci-value |
| 123 | + MCP_SECRET_GITHUB_TOKEN: fake-token-ci-value |
| 124 | + run: go test -v -timeout 600s ./test/... |
| 125 | + |
| 126 | + docker-manifest: |
| 127 | + name: Docker Manifests |
| 128 | + needs: [docker-build] |
| 129 | + if: always() && needs.docker-build.result == 'success' |
| 130 | + runs-on: ubuntu-latest |
| 131 | + steps: |
| 132 | + - name: Set lowercase image name |
| 133 | + run: echo "IMAGE_NAME_LC=${IMAGE_NAME,,}" >> $GITHUB_ENV |
| 134 | + env: |
| 135 | + IMAGE_NAME: ${{ github.repository }} |
| 136 | + |
| 137 | + - name: Log in to GitHub Container Registry |
| 138 | + uses: docker/login-action@v3 |
| 139 | + with: |
| 140 | + registry: ${{ env.REGISTRY }} |
| 141 | + username: ${{ github.actor }} |
| 142 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 143 | + |
| 144 | + - name: Create manifests |
| 145 | + run: | |
| 146 | + R=${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LC }} |
| 147 | + for suffix in "" "-nix" "-ultimate"; do |
| 148 | + docker buildx imagetools create \ |
| 149 | + -t "${R}:dev${suffix}" \ |
| 150 | + -t "${R}:v0.0.0${suffix}" \ |
| 151 | + "${R}:v0.0.0-amd64${suffix}" \ |
| 152 | + "${R}:v0.0.0-arm64${suffix}" |
| 153 | + done |
| 154 | +
|
| 155 | + cell-build: |
| 156 | + name: Cell CLI Dev Build |
| 157 | + needs: secrets |
| 158 | + runs-on: ubuntu-latest |
| 159 | + env: |
| 160 | + RELEASE_VERSION: v0.0.0 |
| 161 | + steps: |
| 162 | + - uses: actions/checkout@v4 |
| 163 | + with: |
| 164 | + fetch-depth: 0 |
| 165 | + |
| 166 | + - name: Set up Go |
| 167 | + uses: actions/setup-go@v5 |
| 168 | + with: |
| 169 | + go-version-file: go.mod |
| 170 | + cache-dependency-path: go.sum |
| 171 | + |
| 172 | + - name: Set SHORT_SHA |
| 173 | + run: echo "SHORT_SHA=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_ENV |
| 174 | + |
| 175 | + - name: Delete existing tag |
| 176 | + run: | |
| 177 | + git config --global user.email "dmitry@atd.sh" |
| 178 | + git config --global user.name "Dmitry Kireev" |
| 179 | + git tag -d "${{ env.RELEASE_VERSION }}" || echo "No local tag to delete" |
| 180 | + git push origin :refs/tags/${{ env.RELEASE_VERSION }} || echo "No remote tag to delete" |
| 181 | +
|
| 182 | + - name: Add tag |
| 183 | + run: | |
| 184 | + git tag -a ${{ env.RELEASE_VERSION }} -m "Development release" |
| 185 | + git push origin ${{ github.ref_name }} |
| 186 | +
|
| 187 | + - name: Run GoReleaser |
| 188 | + uses: goreleaser/goreleaser-action@v6 |
| 189 | + with: |
| 190 | + distribution: goreleaser |
| 191 | + version: "~> v2" |
| 192 | + args: release --clean -f .goreleaser.dev.yaml |
| 193 | + env: |
| 194 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 195 | + HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} |
| 196 | + SHORT_SHA: ${{ env.SHORT_SHA }} |
| 197 | + |
| 198 | + - name: Publish release |
| 199 | + env: |
| 200 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 201 | + run: gh release edit "${{ env.RELEASE_VERSION }}" --draft=false --latest=false |
| 202 | + |
| 203 | + deploy-site: |
| 204 | + name: Deploy Site |
| 205 | + needs: secrets |
| 206 | + if: github.ref == 'refs/heads/main' |
| 207 | + runs-on: ubuntu-latest |
| 208 | + environment: |
| 209 | + name: github-pages |
| 210 | + url: ${{ steps.deployment.outputs.page_url }} |
| 211 | + steps: |
| 212 | + - uses: actions/checkout@v4 |
| 213 | + |
| 214 | + - name: Setup Node |
| 215 | + uses: actions/setup-node@v4 |
| 216 | + with: |
| 217 | + node-version: 20 |
| 218 | + cache: npm |
| 219 | + cache-dependency-path: web/package-lock.json |
| 220 | + |
| 221 | + - name: Setup Pages |
| 222 | + uses: actions/configure-pages@v5 |
| 223 | + |
| 224 | + - name: Install dependencies |
| 225 | + run: npm ci |
| 226 | + working-directory: web |
| 227 | + |
| 228 | + - name: Build with Astro |
| 229 | + run: npm run build |
| 230 | + working-directory: web |
| 231 | + |
| 232 | + - name: Upload artifact |
| 233 | + uses: actions/upload-pages-artifact@v3 |
| 234 | + with: |
| 235 | + path: ./web/dist |
| 236 | + |
| 237 | + - name: Deploy to GitHub Pages |
| 238 | + id: deployment |
| 239 | + uses: actions/deploy-pages@v4 |
0 commit comments