diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 16423b4..31f7938 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -34,7 +34,7 @@ jobs: run: | make start make install-test-pod - make install-cilium-policy + make install-policy-viewer - name: Test working-directory: e2e run: make test diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..33a0a69 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,47 @@ +name: Release +on: + workflow_dispatch: + inputs: + tag: + type: string + required: true + description: The name of the tag to release (X.Y.Z) +jobs: + release: + name: Release network-policy-viewer + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + ref: main + - name: Validate inputs + run: | + if [[ ! ${{ inputs.tag }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Invalid tag format. Please use X.Y.Z" + exit 1 + fi + if git rev-parse v${{ inputs.tag }} >/dev/null 2>&1; then + echo "Tag v${{ inputs.tag }} already exists" + exit 1 + fi + - uses: actions/setup-go@v4 + with: + go-version-file: go.mod + - name: Build + run: | + make build + cd bin; tar -czvf npv_v${{ inputs.tag }}_amd64.tar.gz npv + - name: Setup Git Config + run: | + git config --global user.name github-actions + git config --global user.email github-actions@github.com + - name: Push tag + run: | + git tag -a v${{ inputs.tag }} -m "Release network-policy-viewer v${{ inputs.tag }}" + git push origin v${{ inputs.tag }} + - name: Create release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create v${{ inputs.tag }} --title "Release v${{ inputs.tag }}" --generate-notes + gh release upload v${{ inputs.tag }} bin/npv_v${{ inputs.tag }}_amd64.tar.gz --clobber diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 2bacd2d..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,12 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -This project adheres to [Semantic Versioning](http://semver.org/). - -## [Unreleased] - -### Added -### Changed -### Removed - -[Unreleased]: https://github.com/cybozu-go/cilium-policy-viewer/compare/bd1159a58c5bffddf20a186decd8d511aab5fe68...HEAD diff --git a/Makefile b/Makefile index 1faf806..c6c7b17 100644 --- a/Makefile +++ b/Makefile @@ -76,9 +76,9 @@ clean: ##@ Development .PHONY: build -build: ## Build cilium-policy-viewer +build: ## Build network-policy-viewer mkdir -p $(BIN_DIR) - go build -o $(BIN_DIR)/cilium-policy main.go + go build -trimpath -ldflags "-w -s" -o $(BIN_DIR)/npv main.go .PHONY: check-generate check-generate: diff --git a/README.md b/README.md index 55bd4d4..4d70af7 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -[![GitHub release](https://img.shields.io/github/release/cybozu-go/cilium-policy-viewer.svg?maxAge=60)][releases] -[![CI](https://github.com/cybozu-go/cilium-policy-viewer/actions/workflows/ci.yaml/badge.svg)](https://github.com/cybozu-go/cilium-policy-viewer/actions/workflows/ci.yaml) -[![PkgGoDev](https://pkg.go.dev/badge/github.com/cybozu-go/cilium-policy-viewer?tab=overview)](https://pkg.go.dev/github.com/cybozu-go/cilium-policy-viewer?tab=overview) -[![Go Report Card](https://goreportcard.com/badge/github.com/cybozu-go/cilium-policy-viewer)](https://goreportcard.com/report/github.com/cybozu-go/cilium-policy-viewer) +[![GitHub release](https://img.shields.io/github/release/cybozu-go/network-policy-viewer.svg?maxAge=60)][releases] +[![CI](https://github.com/cybozu-go/network-policy-viewer/actions/workflows/ci.yaml/badge.svg)](https://github.com/cybozu-go/network-policy-viewer/actions/workflows/ci.yaml) +[![PkgGoDev](https://pkg.go.dev/badge/github.com/cybozu-go/network-policy-viewer?tab=overview)](https://pkg.go.dev/github.com/cybozu-go/network-policy-viewer?tab=overview) +[![Go Report Card](https://goreportcard.com/badge/github.com/cybozu-go/network-policy-viewer)](https://goreportcard.com/report/github.com/cybozu-go/network-policy-viewer) -Cilium Policy Viewer -==================== +Network Policy Viewer +===================== **Project Status**: Initial development @@ -12,4 +12,4 @@ Cilium Policy Viewer [docs](docs/) directory contains documents about designs and specifications. -[releases]: https://github.com/cybozu-go/cilium-policy-viewer/releases +[releases]: https://github.com/cybozu-go/network-policy-viewer/releases diff --git a/docs/release.md b/docs/release.md index 5bdd2a8..fa592fb 100644 --- a/docs/release.md +++ b/docs/release.md @@ -7,68 +7,10 @@ This document describes how to release a new version. Follow [semantic versioning 2.0.0][semver] to choose the new version number. -## Prepare change log entries - -Add notable changes since the last release to [CHANGELOG.md](CHANGELOG.md). -It should look like: - -```markdown -(snip) -## [Unreleased] - -### Added -- Implement ... (#35) - -### Changed -- Fix a bug in ... (#33) - -### Removed -- Deprecated `-option` is removed ... (#39) - -(snip) -``` - ## Bump version -1. Determine a new version number. Then set `VERSION` variable. - - ```console - # Set VERSION and confirm it. It should not have "v" prefix. - $ VERSION=x.y.z - $ echo $VERSION - ``` - -2. Make a branch to release - - ```console - $ git neco dev "bump-$VERSION" - ``` - -3. Edit `CHANGELOG.md` for the new version ([example][]). -4. Commit the change and push it. - - ```console - $ git commit -a -m "Bump version to $VERSION" - $ git neco review - ``` - -5. Merge this branch. -6. Add a git tag to the main HEAD, then push it. - - ```console - # Set VERSION again. - $ VERSION=x.y.z - $ echo $VERSION - - $ git checkout main - $ git pull - $ git tag -a -m "Release v$VERSION" "v$VERSION" - - # Make sure the release tag exists. - $ git tag -ln | grep $VERSION - - $ git push origin "v$VERSION" - ``` +1. Go to Actions on GitHub Web UI and select Release job. +2. Run the workflow with an appropriate version number. GitHub actions will build and push artifacts such as container images and create a new GitHub release. diff --git a/e2e/Makefile b/e2e/Makefile index a6264b9..ced9aaa 100644 --- a/e2e/Makefile +++ b/e2e/Makefile @@ -4,7 +4,7 @@ BIN_DIR := $(shell pwd)/../bin TOOLS_DIR := $(BIN_DIR)/download CACHE_DIR := $(shell pwd)/../cache -CILIUM_POLICY := $(BIN_DIR)/cilium-policy +POLICY_VIEWER := $(BIN_DIR)/npv HELM := $(TOOLS_DIR)/helm --repository-cache $(CACHE_DIR)/helm/repository --repository-config $(CACHE_DIR)/helm/repositories.yaml KIND := $(TOOLS_DIR)/kind KUBECTL := $(TOOLS_DIR)/kubectl @@ -54,12 +54,12 @@ install-test-pod: $(MAKE) --no-print-directory wait-for-workloads $(KUBECTL) apply -f testdata/policy/l3.yaml -.PHONY: install-cilium-policy -install-cilium-policy: +.PHONY: install-policy-viewer +install-policy-viewer: $(MAKE) -C ../ build PODNAME=$$($(KUBECTL) get po -l app=ubuntu -o name | cut -d'/' -f2); \ - $(KUBECTL) cp $(CILIUM_POLICY) $${PODNAME}:/tmp/; \ - $(KUBECTL) exec $${PODNAME} -- chmod +x /tmp/cilium-policy + $(KUBECTL) cp $(POLICY_VIEWER) $${PODNAME}:/tmp/; \ + $(KUBECTL) exec $${PODNAME} -- chmod +x /tmp/npv .PHONY: test test: diff --git a/e2e/suite_test.go b/e2e/suite_test.go index 36b12a1..250b5be 100644 --- a/e2e/suite_test.go +++ b/e2e/suite_test.go @@ -18,7 +18,7 @@ var _ = BeforeSuite(func() { SetDefaultEventuallyTimeout(5 * time.Minute) }) -var _ = Describe("Test cilium-policy-viewer", func() { +var _ = Describe("Test network-policy-viewer", func() { runTest() }) diff --git a/e2e/utils_test.go b/e2e/utils_test.go index 89dd408..e3fd172 100644 --- a/e2e/utils_test.go +++ b/e2e/utils_test.go @@ -14,7 +14,7 @@ import ( const ( jqPath = "../bin/download/jq" kubectlPath = "../bin/download/kubectl" - policyViewerPath = "/tmp/cilium-policy" + policyViewerPath = "/tmp/npv" ) func runCommand(path string, input []byte, args ...string) ([]byte, []byte, error) { diff --git a/go.mod b/go.mod index 143d140..7dba7a5 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/cybozu-go/cilium-policy-viewer +module github.com/cybozu-go/network-policy-viewer go 1.22.1 diff --git a/main.go b/main.go index 5a8ab97..8b925ad 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,7 @@ package main import ( - "github.com/cybozu-go/cilium-policy-viewer/cmd" + "github.com/cybozu-go/network-policy-viewer/cmd" ) func main() {