From 61dc0c7e106b130052880e02fc4efece286a53ab Mon Sep 17 00:00:00 2001 From: peterdeme Date: Tue, 9 May 2023 15:41:02 +0200 Subject: [PATCH] Add container release to `spacectl` Signed-off-by: peterdeme --- .github/workflows/release.yml | 24 +++++++++++++++++++++--- .goreleaser.yml | 22 ++++++++++++++++++++++ Dockerfile | 3 +++ README.md | 10 ++++++++++ 4 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ee2810b..6d5f3a7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,6 +6,10 @@ jobs: goreleaser: name: Release runs-on: ubuntu-latest + permissions: + id-token: write + contents: write + packages: write steps: - name: Checkout @@ -16,6 +20,21 @@ jobs: uses: actions/setup-go@v4 with: { go-version: 1.19 } + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + with: { platforms: linux/arm64 } + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + if: startsWith(github.ref, 'refs/tags/v') + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Import GPG key id: import_gpg uses: crazy-max/ghaction-import-gpg@v5 @@ -30,11 +49,10 @@ jobs: - name: Run GoReleaser uses: goreleaser/goreleaser-action@v4 - if: startsWith(github.ref, 'refs/tags/') with: version: latest - args: release --rm-dist + args: release --clean ${{ startsWith(github.ref, 'refs/tags/v') && '' || '--snapshot' }} env: GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} + HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} \ No newline at end of file diff --git a/.goreleaser.yml b/.goreleaser.yml index 6fad01b..f6c04ce 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -14,6 +14,28 @@ archives: - format: zip name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" +dockers: + - use: buildx + goarch: amd64 + build_flag_templates: ["--platform=linux/amd64"] + image_templates: ["ghcr.io/spacelift-io/spacectl:{{ .Version }}-amd64"] + + - use: buildx + goarch: arm64 + build_flag_templates: ["--platform=linux/arm64"] + image_templates: ["ghcr.io/spacelift-io/spacectl:{{ .Version }}-arm64"] + +docker_manifests: + - name_template: ghcr.io/spacelift-io/spacectl:{{ .Version }} + image_templates: + - ghcr.io/spacelift-io/spacectl:{{ .Version }}-amd64 + - ghcr.io/spacelift-io/spacectl:{{ .Version }}-arm64 + + - name_template: ghcr.io/spacelift-io/spacectl:latest + image_templates: + - ghcr.io/spacelift-io/spacectl:{{ .Version }}-amd64 + - ghcr.io/spacelift-io/spacectl:{{ .Version }}-arm64 + checksum: name_template: "{{ .ProjectName }}_{{ .Version }}_SHA256SUMS" algorithm: sha256 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d9e0634 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,3 @@ +FROM alpine +COPY spacectl /usr/local/bin/spacectl +ENTRYPOINT ["/usr/local/bin/spacectl"] \ No newline at end of file diff --git a/README.md b/README.md index 41a9359..6ab2e6d 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,16 @@ asdf install spacectl latest asdf global spacectl latest ``` +### Docker image + +`spacectl` is distributed as a Docker image, which can be used as follows: + +```bash +docker run -it --rm ghcr.io/spacelift-io/spacectl stack deploy --id my-infra-stack +``` + +> Don't forget to add the [requied environment variables](#authenticating-using-environment-variables) in order to authenticate. + ### GitHub Release Alternatively, `spacectl` is distributed through GitHub Releases as a zip file containing a self-contained statically linked executable built from the source in this repository. Binaries can be download directly from the [Releases page](https://github.com/spacelift-io/spacectl/releases).