Skip to content

Commit

Permalink
Add release workflow (#6)
Browse files Browse the repository at this point in the history
* Rename repository
* Rename command
* Add release workflow
* Update Makefile

Signed-off-by: Daichi Sakaue <[email protected]>
Co-authored-by: Tomoki Sugiura <[email protected]>
  • Loading branch information
yokaze and chez-shanpu authored Oct 9, 2024
1 parent 90b7e0f commit 5c23e7d
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 91 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
47 changes: 47 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -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 [email protected]
- 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
12 changes: 0 additions & 12 deletions CHANGELOG.md

This file was deleted.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[![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

## Documentation

[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
62 changes: 2 additions & 60 deletions docs/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions e2e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})

Expand Down
2 changes: 1 addition & 1 deletion e2e/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/cybozu-go/cilium-policy-viewer
module github.com/cybozu-go/network-policy-viewer

go 1.22.1

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down

0 comments on commit 5c23e7d

Please sign in to comment.