Skip to content

Commit

Permalink
Add release workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Daichi Sakaue <[email protected]>
  • Loading branch information
yokaze committed Oct 8, 2024
1 parent 56a1b0e commit 9d5d098
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 73 deletions.
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.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ clean:
.PHONY: build
build: ## Build network-policy-viewer
mkdir -p $(BIN_DIR)
go build -o $(BIN_DIR)/npv main.go
CGO_ENABLED=0 go build -trimpath -ldflags "-w -s" -o $(BIN_DIR)/npv main.go

.PHONY: check-generate
check-generate:
Expand Down
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

0 comments on commit 9d5d098

Please sign in to comment.