Skip to content

Commit

Permalink
v0.0.22: windows msi & chocolatey support
Browse files Browse the repository at this point in the history
  • Loading branch information
benburkert committed Apr 15, 2024
1 parent f26a350 commit c0a7f7a
Show file tree
Hide file tree
Showing 46 changed files with 991 additions and 97 deletions.
111 changes: 108 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,70 @@ name: Release
concurrency: release

on:
workflow_dispatch:
push:
branches:
- main
tags: ["v*"]

permissions:
contents: write
packages: write
id-token: write

jobs:
prepare:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
- shell: bash
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- uses: actions/cache@v4
if: matrix.os == 'ubuntu-latest'
with:
path: cmd/anchor/dist/linux
key: linux-${{ env.sha_short }}
- uses: actions/cache@v4
if: matrix.os == 'macos-latest'
with:
path: cmd/anchor/dist/darwin
key: darwin-${{ env.sha_short }}
- uses: actions/cache@v4
if: matrix.os == 'windows-latest'
with:
path: cmd/anchor/dist/windows
key: windows-${{ env.sha_short }}
enableCrossOsArchive: true
- name: non-windows flags
if: matrix.os != 'windows-latest'
shell: bash
run: echo 'flags=--skip chocolatey' >> $GITHUB_ENV
- name: windows flags
if: matrix.os == 'windows-latest'
shell: bash
run: echo 'flags=--skip homebrew' >> $GITHUB_ENV
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser-pro
version: latest
args: release --clean --split ${{ env.flags }}
workdir: cmd/anchor
env:
GITHUB_TOKEN: ${{ secrets._GITHUB_TOKEN }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
release:
runs-on: ubuntu-latest
needs: prepare
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -19,13 +76,61 @@ jobs:
uses: actions/setup-go@v4
with:
go-version-file: go.mod

# Copy Caches
- shell: bash
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- uses: actions/cache@v4
with:
path: cmd/anchor/dist/linux
key: linux-${{ env.sha_short }}
- uses: actions/cache@v4
with:
path: cmd/anchor/dist/darwin
key: darwin-${{ env.sha_short }}
- uses: actions/cache@v4
with:
path: cmd/anchor/dist/windows
key: windows-${{ env.sha_short }}
enableCrossOsArchive: true

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser-pro
version: latest
args: release --clean
args: continue --merge
workdir: cmd/anchor
env:
GITHUB_TOKEN: ${{ secrets._GITHUB_TOKEN }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

publish-windows:
runs-on: windows-latest
needs: prepare
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

# Copy Caches
- shell: bash
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
- uses: actions/cache@v4
with:
path: cmd/anchor/dist/windows
key: windows-${{ env.sha_short }}
enableCrossOsArchive: true
- shell: bash
run: |
cp cmd/anchor/dist/windows/anchor.${{ env.RELEASE_VERSION }}.nupkg ./
- shell: pwsh
run: |
choco push --source https://push.chocolatey.org/ --api-key "$env:CHOCOLATEY_API_KEY" anchor.${{ env.RELEASE_VERSION }}.nupkg
env:
CHOCOLATEY_API_KEY: ${{ secrets.CHOCOLATEY_API_KEY }}
9 changes: 6 additions & 3 deletions auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"flag"
"testing"

"github.com/anchordotdev/cli"
"github.com/anchordotdev/cli/api/apitest"
"github.com/anchordotdev/cli/cmdtest"
)
Expand All @@ -27,13 +28,15 @@ func TestMain(m *testing.M) {

func TestCmdAuth(t *testing.T) {
cmd := CmdAuth
root := cmd.Root()
cfg := cli.ConfigFromCmd(cmd)
cfg.Test.SkipRunE = true

t.Run("auth", func(t *testing.T) {
cmdtest.TestOutput(t, root, "auth")
cfg.Test.SkipRunE = false
cmdtest.TestOutput(t, cmd, "auth")
})

t.Run("--help", func(t *testing.T) {
cmdtest.TestOutput(t, root, "auth", "--help")
cmdtest.TestOutput(t, cmd, "auth", "--help")
})
}
6 changes: 4 additions & 2 deletions auth/signin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ package auth
import (
"testing"

"github.com/anchordotdev/cli"
"github.com/anchordotdev/cli/cmdtest"
)

func TestCmdAuthSignin(t *testing.T) {
cmd := CmdAuthSignin
root := cmd.Root()
cfg := cli.ConfigFromCmd(cmd)
cfg.Test.SkipRunE = true

t.Run("--help", func(t *testing.T) {
cmdtest.TestOutput(t, root, "auth", "signin", "--help")
cmdtest.TestOutput(t, cmd, "auth", "signin", "--help")
})
}

Expand Down
3 changes: 1 addition & 2 deletions auth/signout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ func TestCmdAuthSignout(t *testing.T) {
cmd := CmdAuthSignin
cfg := cli.ConfigFromCmd(cmd)
cfg.Test.SkipRunE = true
root := cmd.Root()

t.Run("--help", func(t *testing.T) {
cmdtest.TestOutput(t, root, "auth", "signout", "--help")
cmdtest.TestOutput(t, cmd, "auth", "signout", "--help")
})
}

Expand Down
3 changes: 1 addition & 2 deletions auth/whoami_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ func TestCmdAuthWhoAmI(t *testing.T) {
cmd := CmdAuthWhoami
cfg := cli.ConfigFromCmd(cmd)
cfg.Test.SkipRunE = true
root := cmd.Root()

t.Run("--help", func(t *testing.T) {
cmdtest.TestOutput(t, root, "auth", "whoami", "--help")
cmdtest.TestOutput(t, cmd, "auth", "whoami", "--help")
})

}
Expand Down
10 changes: 3 additions & 7 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,12 @@ type Config struct {
} `cmd:"config"`

MkCert struct {
Domains string `flag:"domains"`
SubCa string `flag:"subca"`
Domains []string `flag:"domains"`
SubCa string `flag:"subca"`
} `cmd:"mkcert"`

Setup struct {
PackageManager string `desc:"Package manager to use for integrating Anchor." flag:"package-manager" env:"PACKAGE_MANAGER" json:"package_manager" toml:"package-manager"`
Service string `desc:"Name for lcl.host service." flag:"service" env:"SERVICE" json:"service" toml:"service"`
Subdomain string `desc:"Subdomain for lcl.host service." flag:"subdomain" env:"SUBDOMAIN" json:"subdomain" toml:"subdomain"`
File string `desc:"File Anchor should use to detect package manager." flag:"file" env:"PACKAGE_MANAGER_FILE" json:"file" toml:"file"`
Language string `desc:"Language to use for integrating Anchor." flag:"language" json:"language" toml:"language"`
Language string `desc:"Language to use for integrating Anchor." flag:"language" json:"language" toml:"language"`
} `cmd:"setup"`
} `cmd:"lcl"`

Expand Down
66 changes: 65 additions & 1 deletion cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ var rootDef = CmdDef{
{
Name: "lcl",

Use: "lcl <subcommand> [flags]",
Use: "lcl [flags]",
Short: "Manage lcl.host Local Development Environment",

SubDefs: []CmdDef{
Expand All @@ -87,13 +87,77 @@ var rootDef = CmdDef{
Use: "audit [flags]",
Short: "Audit lcl.host HTTPS Local Development Environment",
},
{
Name: "clean",

Use: "clean [flags]",
Short: "Clean lcl.host CA Certificates from the Local Trust Store(s)",
},
{
Name: "config",

Use: "config [flags]",
Short: "Configure System for lcl.host Local Development",
},
{
Name: "mkcert",

Use: "mkcert [flags]",
Short: "Provision Certificate for lcl.host Local Development",
},
{
Name: "setup",

Use: "setup [flags]",
Short: "Setup lcl.host Application",
},
},
},
{
Name: "trust",

Use: "trust [flags]",
Short: "Manage CA Certificates in your Local Trust Store(s)",
Long: heredoc.Doc(`
Install the AnchorCA certificates of a target organization, realm, or CA into
your local system's trust store. The default target is the localhost realm of
your personal organization.
After installation of the AnchorCA certificates, Leaf certificates under the
AnchorCA certificates will be trusted by browsers and programs on your system.
`),
SubDefs: []CmdDef{
{
Name: "audit",

Use: "audit [flags]",
Short: "Audit CA Certificates in your Local Trust Store(s)",
Long: heredoc.Doc(`
Perform an audit of the local trust store(s) and report any expected, missing,
or extra CA certificates per store. A set of expected CAs is fetched for the
target org and (optional) realm. The default stores to audit are system, nss,
and homebrew.
CA certificate states:
* VALID: an expected CA certificate is present in every trust store.
* MISSING: an expected CA certificate is missing in one or more stores.
* EXTRA: an unexpected CA certificate is present in one or more stores.
`),
},
{
Name: "clean",

Use: "clean [flags]",
Short: "Clean CA Certificates from your Local Trust Store(s)",
},
},
},
{
Name: "version",

Use: "version",
Short: "Show version info",
},
},
}
Expand Down
Loading

0 comments on commit c0a7f7a

Please sign in to comment.