Skip to content
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
51 changes: 50 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: Release

# Builds plugctl for each platform and publishes a GitHub release with the archives, plus the
# container image ghcr.io/zompinc/plugctl built from the Linux binaries.
# container image ghcr.io/zompinc/plugctl built from the Linux binaries. Both carry build
# provenance: `gh attestation verify <file> -R zompinc/plugctl` (or oci://<image>) checks that
# this workflow built them, and from which commit.
#
# - Run it from the Actions tab (workflow_dispatch) on master: it tags the commit with the
# version Nerdbank.GitVersioning calculates and publishes.
Expand Down Expand Up @@ -71,6 +73,9 @@ jobs:

# Hosted runners: this repository is public.
runs-on: ${{ matrix.os }}
env:
# Whether the signing secrets are available, without putting them in every step's env.
CAN_SIGN: ${{ secrets.AZURE_SIGNER_CLIENT_SECRET != '' }}

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -98,6 +103,34 @@ jobs:
cargo build --release --locked --target ${{ matrix.target }}
fi

# Authenticode-signs plugctl.exe with Zomp's Azure Trusted Signing account, so SmartScreen
# and Smart App Control see a known publisher. sign-universal is Zomp's own signer
# (github.com/zompinc/sign-universal). The secrets are organization secrets, which pull
# requests from forks do not get, so those build unsigned.
- name: Sign
if: ${{ runner.os == 'Windows' && !env.ACT && env.CAN_SIGN == 'true' }}
shell: pwsh
# sign-universal reads these, as DefaultAzureCredential does.
env:
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_CLIENT_ID: ${{ secrets.AZURE_SIGNER_CLIENT_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_SIGNER_CLIENT_SECRET }}
run: |
dotnet tool install SignUniversal.Cli --version 1.0.39 --tool-path "$env:RUNNER_TEMP/sign"
$su = "$env:RUNNER_TEMP/sign/sign-universal"
$exe = "target/${{ matrix.target }}/release/plugctl.exe"
& $su sign $exe `
--trusted-signing-endpoint "${{ secrets.TRUSTED_SIGNING_ENDPOINT }}" `
--trusted-signing-account "${{ secrets.TRUSTED_SIGNING_ACCOUNT }}" `
--trusted-signing-certificate-profile "${{ secrets.TRUSTED_SIGNING_CERTIFICATE_PROFILE }}"
if ($LASTEXITCODE) { exit $LASTEXITCODE }
& $su verify $exe
if ($LASTEXITCODE) { exit $LASTEXITCODE }
# verify leaves trust to Windows; this asks Windows whether it trusts the chain.
$sig = Get-AuthenticodeSignature $exe
"$($sig.Status): $($sig.SignerCertificate.Subject)"
if ($sig.Status -ne 'Valid') { exit 1 }

- name: Package
shell: bash
run: |
Expand All @@ -124,6 +157,9 @@ jobs:
permissions:
contents: read
packages: write
# For the provenance attestation: a GitHub OIDC token to sign it, and the right to store it.
id-token: write
attestations: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
Expand Down Expand Up @@ -161,6 +197,7 @@ jobs:
username: ${{ github.actor }}
password: ${{ github.token }}
- uses: docker/build-push-action@v6
id: push
with:
context: .
platforms: linux/amd64,linux/arm64
Expand All @@ -173,19 +210,31 @@ jobs:
org.opencontainers.image.version=${{ needs.version.outputs.version }}
org.opencontainers.image.licenses=MIT
org.opencontainers.image.description=Switch or power-cycle smart plugs by MAC
- uses: actions/attest-build-provenance@v4
if: ${{ github.event_name != 'pull_request' }}
with:
subject-name: ghcr.io/${{ github.repository }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true

publish:
needs: [version, build, image]
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
attestations: write
steps:
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true

- uses: actions/attest-build-provenance@v4
with:
subject-path: dist/*

- name: Publish
env:
GH_TOKEN: ${{ github.token }}
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ TP-Link Kasa plugs come first, including firmware that only accepts KLAP (the en

Download the archive for your platform from [Releases](https://github.com/zompinc/plugctl/releases) and put `plugctl` (or `plugctl.exe`) on your `PATH`. There are static Linux builds for x86_64 and aarch64 (which also run on aarch64 OpenWrt routers), Windows x86_64, and macOS on Apple silicon and Intel. `SHA256SUMS` lists each archive's checksum.

Each archive and image carries a build provenance attestation, which shows that this repository's release workflow built it and from which commit:

```sh
gh attestation verify plugctl-<version>-<target>.tar.gz -R zompinc/plugctl
gh attestation verify oci://ghcr.io/zompinc/plugctl:<version> -R zompinc/plugctl
```

The Windows binary is Authenticode-signed by Zomp Inc.; the macOS binaries are not signed yet. On macOS, a binary downloaded with a browser needs `xattr -d com.apple.quarantine plugctl` before it runs.

### Container

Each release is also an image for linux/amd64 and linux/arm64, `ghcr.io/zompinc/plugctl:<version>` (`latest` follows stable releases only). It keeps the config and the off-time log in `/config`, and takes the login from the environment, since there is no keyring in a container:
Expand Down
Loading