Skip to content

Commit

Permalink
Give ZDNS a version (#384)
Browse files Browse the repository at this point in the history
* added version to cli.go

* added zdns version into metadata

* added comment explaining usage to version tag workflow

* re-worked version tag action

* fixed sed
  • Loading branch information
phillip-stephens authored Jun 11, 2024
1 parent 67026d0 commit 79f8a8a
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/version_tagging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Release on Demand

on:
workflow_dispatch:
inputs:
version:
description: 'Semantic version for the release, ex: "v1.2.3"'
required: true

jobs:
create-release:
runs-on: ubuntu-latest

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

- name: Set up Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Create release branch
id: create_branch
run: |
VERSION=${{ github.event.inputs.version }}
BRANCH_NAME="release/${VERSION}"
git checkout -b ${BRANCH_NAME}
echo "Branch name is ${BRANCH_NAME}"
- name: Update version in cli.go
run: |
VERSION=${{ github.event.inputs.version }}
sed 's/\tzdnsCLIVersion = \".*\"/\tzdnsCLIVersion = \"${VERSION}\"/g' src/cli/cli.go
- name: Commit changes
run: |
VERSION=${{ github.event.inputs.version }}
git add src/cli/cli.go
git commit -m "Update version to ${VERSION} in src/cli/cli.go"
- name: Push branch
run: |
VERSION=${{ github.event.inputs.version }}
BRANCH_NAME="release/${VERSION}"
git push origin ${BRANCH_NAME}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: "release/${{ github.event.inputs.version }}"
title: "Release ${VERSION}"
body: "This PR updates the version to ${VERSION}. Be sure to tag the release once this PR is merged."
base: main
5 changes: 5 additions & 0 deletions src/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ import (
"github.com/zmap/zdns/src/internal/util"
)

const (
zdnsCLIVersion = "1.1.0"
)

type InputHandler interface {
FeedChannel(in chan<- string, wg *sync.WaitGroup) error
}
Expand Down Expand Up @@ -106,6 +110,7 @@ ZDNS also includes its own recursive resolution and a cache to further optimize
GC.Module = strings.ToUpper(args[0])
Run(GC, cmd.Flags())
},
Version: zdnsCLIVersion,
}

// Execute adds all child commands to the root command and sets flags appropriately.
Expand Down
2 changes: 2 additions & 0 deletions src/cli/worker_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type Metadata struct {
Timeout int `json:"timeout"`
Retries int `json:"retries"`
Conf *CLIConf `json:"conf"`
ZDNSVersion string `json:"zdns_version"`
}

func populateCLIConfig(gc *CLIConf, flags *pflag.FlagSet) *CLIConf {
Expand Down Expand Up @@ -540,6 +541,7 @@ func makeName(name, prefix, nameOverride string) (string, bool) {

func aggregateMetadata(c <-chan routineMetadata) Metadata {
var meta Metadata
meta.ZDNSVersion = zdnsCLIVersion
meta.Status = make(map[string]int)
for m := range c {
meta.Names += m.Names
Expand Down

0 comments on commit 79f8a8a

Please sign in to comment.