Skip to content

Commit

Permalink
ci: use windows for base deploy action (#20)
Browse files Browse the repository at this point in the history
* ci: use windows for base deploy action

* docs: better description

* chore: add icon to choco

* ci: change bash cmds to ps friendly ones

* feat: add version command

* GH ACTION TEST

* TEST 2

* TEST 3

* TEST 4

* TEST 5

* TEST 6

* ci: fix powershell env version variables
  • Loading branch information
ayuhito committed Feb 18, 2023
1 parent 611a073 commit c8f0b17
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 89 deletions.
29 changes: 4 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ permissions:

jobs:
goreleaser:
runs-on: ubuntu-latest
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -31,8 +31,9 @@ jobs:
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GHTOKEN_GORELEASER }}
CHOCOLATEY_APIKEY: ${{ secrets.CHOCOLATEY_APIKEY }}

- run: echo "VERSION_NAME=${GITHUB_REF_NAME:1}" >> $GITHUB_ENV
- run: echo ("VERSION_NAME=" + $env:GITHUB_REF_NAME.TrimStart("v")) >> $env:GITHUB_ENV
- run: echo $VERSION_NAME
- uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -62,26 +63,4 @@ jobs:
RPM-PACKAGE-NAME: globalping_${{ env.VERSION_NAME }}_linux_amd64.rpm
PACKAGECLOUD-USERNAME: jsdelivr
PACKAGECLOUD-REPO: globalping
PACKAGECLOUD-TOKEN: ${{ secrets.PACKAGECLOUD_APIKEY }}

choco:
runs-on: windows-latest

steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-go@v3
with:
go-version: '>=1.20.0'
cache: true

- uses: goreleaser/goreleaser-action@v4
with:
version: ${{ env.GITHUB_REF_NAME }}
args: release --clean -f .goreleaser.choco.yaml
env:
GITHUB_TOKEN: ${{ secrets.GHTOKEN_GORELEASER }}
CHOCOLATEY_APIKEY: ${{ secrets.CHOCOLATEY_APIKEY }}
PACKAGECLOUD-TOKEN: ${{ secrets.PACKAGECLOUD_APIKEY }}
59 changes: 0 additions & 59 deletions .goreleaser.choco.yaml

This file was deleted.

46 changes: 46 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,51 @@ brews:
commit_author:
name: jimaek
email: dakulovgr@gmail.com

chocolateys:
-
name: globalping
owners: jsdelivr
title: Globalping CLI
authors: Ayuhito

project_url: https://www.jsdelivr.com/globalping

# App's icon.
icon_url: 'https://avatars.githubusercontent.com/u/102991324?v=4'

license_url: https://github.com/jsdelivr/globalping-cli/blob/master/LICENSE
project_source_url: https://github.com/jsdelivr/globalping-cli
docs_url: https://github.com/jsdelivr/globalping-cli/blob/master/README.md
bug_tracker_url: https://github.com/jsdelivr/globalping-cli/issues
release_notes: "https://github.com/jsdelivr/globalping-cli/releases/tag/v{{ .Version }}"

summary: A global network of probes to run network tests like ping, traceroute and DNS resolve.
# Supports markdown.
description: |
# Globalping CLI
- The official command-line interface for the [Globalping](https://github.com/jsdelivr/globalping) network.
- Run networking commands from any location in the world
- Supported commands: ping, mtr, traceroute, dns resolve, HTTP
- Real-time results right in your command line
- Human friendly format and output
- Cross-platform. Linux, MacOS, Windows are all supported
- Auto-updates via RPM/DEB/Chocolatey repos
- [Check our website for online tools, our Slack app and more!](https://www.jsdelivr.com/globalping)
## Getting Started with Globalping CLI
Once the Globalping CLI is installed, you can verify that it is working by running:
```bash
globalping --help
```
tags: "globalping ping traceroute dns mtr http network"

api_key: '{{ .Env.CHOCOLATEY_APIKEY }}'


# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ brew tap jsdelivr/globalping
brew install globalping
```

### Windows - Chocolatey
### Windows - [Chocolatey](https://community.chocolatey.org/packages/globalping)

```shell
choco install globalping
Expand Down
8 changes: 5 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ var (
method string
// TODO: headers map[string]string

opts = model.PostMeasurement{}
ctx = model.Context{}
opts = model.PostMeasurement{}
ctx = model.Context{}
version string
)

// rootCmd represents the base command when called without any subcommands
Expand All @@ -40,7 +41,8 @@ var rootCmd = &cobra.Command{

// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
func Execute(ver string) {
version = ver
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
Expand Down
19 changes: 19 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

func init() {
rootCmd.AddCommand(versionCmd)
}

var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version number of Globalping CLI",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Globalping CLI " + version)
},
}
7 changes: 6 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ package main

import "github.com/jsdelivr/globalping-cli/cmd"

var (
// https://goreleaser.com/cookbooks/using-main.version/
version = "dev"
)

func main() {
cmd.Execute()
cmd.Execute(version)
}

0 comments on commit c8f0b17

Please sign in to comment.