Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cosign): Making Cosign installation optional #2

Merged
merged 1 commit into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,31 @@ jobs:
name: Test regctl-installer Action
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
fail-fast: false # let other tests finish
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
cosign: [true, false]

steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Install Cosign
uses: sigstore/cosign-installer@v3.0.1
if: matrix.cosign

- name: Install regctl
uses: ./

- name: Test regctl
run: |
regctl version
regctl tag ls caddy
regctl image digest nginx:latest
regctl image manifest alpine:3.11
run: regctl version

main:
if: ${{ github.event_name == 'push' }}
name: Publish new version
runs-on: ubuntu-latest
needs: [test]

if: github.event_name == 'push'
steps:
- name: Checkout repo
uses: actions/checkout@v3
Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/IAreKyleW00t/regctl-installer/main.yml)](https://github.com/IAreKyleW00t/regctl-installer/actions/workflows/main.yml)
[![License](https://img.shields.io/github/license/IAreKyleW00t/regctl-installer)](https://github.com/IAreKyleW00t/regctl-installer/blob/main/LICENSE)

This GitHub Action enables you to interacting with remote images and registries using [`regctl`](https://github.com/google/go-containerregistry/tree/main/cmd/regctl). This action will verify the integrity of the `regctl` release during installation using [Cosign](https://docs.sigstore.dev/cosign/overview/).
This GitHub Action enables you to interacting with remote images and registries using [`regctl`](https://github.com/google/go-containerregistry/tree/main/cmd/regctl). This action will verify the integrity of the `regctl` release during installation if you setup [Cosign](https://docs.sigstore.dev/cosign/overview/) ahead of time (see examples below).

For a quick start guide on the usage of `regctl`, please refer to https://github.com/regclient/regclient/blob/main/docs/regctl.md. For available regctl releases, see https://github.com/regclient/regclient/releases.

Expand All @@ -18,6 +18,7 @@ For a quick start guide on the usage of `regctl`, please refer to https://github
- [Pinned version](#pinned-version)
- [Default version](#pinned-version)
- [Authenicate on other registries](#authenticate-on-other-registries)
- [Automatic validation with Cosign](#automatic-validation-with-cosign)

## Tags

Expand Down Expand Up @@ -93,6 +94,21 @@ jobs:
--pass-stdin
```

### Automatic validation with Cosign

```yaml
jobs:
regctl:
runs-on: ubuntu-latest
steps:
- name: Install Cosign
uses: sigstore/cosign-installer@v3.0.1
- name: Install regctl
uses: iarekylew00t/regctl-installer@v1
- name: Check install
run: regctl version
```

## Contributing

Feel free to contribute and make things better by opening an [Issue](https://github.com/IAreKyleW00t/regctl-installer/issues) or [Pull Request](https://github.com/IAreKyleW00t/regctl-installer/pulls).
Expand Down
22 changes: 12 additions & 10 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ inputs:
runs:
using: "composite"
steps:
- uses: sigstore/cosign-installer@v3.0.1
- shell: bash
run: |
#!/bin/bash
Expand Down Expand Up @@ -66,15 +65,18 @@ runs:
curl -fsSL "https://github.com/regclient/regclient/releases/download/${VERSION}/regctl-${OS}-${ARCH}${BIN_SUFFIX}" > "${{ inputs.install-dir }}/regctl${BIN_SUFFIX}"
chmod 755 "${{ inputs.install-dir }}/regctl${BIN_SUFFIX}"

# Validate download
curl -fsSL https://github.com/regclient/regclient/releases/latest/download/metadata.tgz > metadata.tgz
tar -xzf metadata.tgz regctl-${OS}-${ARCH}.pem regctl-${OS}-${ARCH}.sig
cosign verify-blob \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
--certificate-identity-regexp https://github.com/regclient/regclient/.github/workflows/ \
--certificate regctl-${OS}-${ARCH}.pem \
--signature regctl-${OS}-${ARCH}.sig \
"${{ inputs.install-dir }}/regctl${BIN_SUFFIX}"
# Validate download (if cosign is setup)
if which cosign >/dev/null; then
curl -fsSL https://github.com/regclient/regclient/releases/latest/download/metadata.tgz > metadata.tgz
tar -xzf metadata.tgz regctl-${OS}-${ARCH}.pem regctl-${OS}-${ARCH}.sig
cosign verify-blob \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
--certificate-identity-regexp https://github.com/regclient/regclient/.github/workflows/ \
--certificate regctl-${OS}-${ARCH}.pem \
--signature regctl-${OS}-${ARCH}.sig \
"${{ inputs.install-dir }}/regctl${BIN_SUFFIX}"
rm -rf metadata.tgz regctl-${OS}-${ARCH}.pem regctl-${OS}-${ARCH}.sig
fi

- if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }}
run: echo "${{ inputs.install-dir }}" >> $GITHUB_PATH
Expand Down