diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml new file mode 100644 index 0000000..a7bc707 --- /dev/null +++ b/.github/workflows/build-and-push.yml @@ -0,0 +1,56 @@ +name: Build and push to GHCR + +on: + push: + branches: + - main + tags: + - 'v*' + +permissions: + contents: read + packages: write + +jobs: + push_to_registry: + name: Build and push Docker image + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + flavor: latest=false + tags: | + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} + type=ref,event=tag + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/README.md b/README.md index 6aeb177..89a397e 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,22 @@ Once the server is running locally, do the following: npm install npm run dev ``` + +## Tag and push a stable release + +The [build-and-push workflow](./.github/workflows/build-and-push.yml) builds and pushes the `latest` image on every push to `main`. Stable releases use version tags in the form `vMAJOR.MINOR.PATCH`, such as `v0.1.0`. + +First, make sure you are tagging the commit you want to release. Then create and push the tag: + +```bash +git tag -a v0.1.0 -m "Release v0.1.0" +git push origin v0.1.0 +``` + +Pushing the tag triggers GitHub Actions to build and push a multi-platform image to GHCR. For the upstream repository, the image is published as: + +```text +ghcr.io/simonsobs/lightview:v0.1.0 +``` + +Check the repository's **Actions** tab to confirm that the build succeeded.