Skip to content

Commit

Permalink
feat: release を作成できるよう変更
Browse files Browse the repository at this point in the history
  • Loading branch information
kokoichi206 committed Jan 30, 2023
1 parent 824aff9 commit 0c55c75
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 2 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: release

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"

jobs:
release:
runs-on: macos-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: setup go
uses: actions/setup-go@v3
with:
go-version: 1.x
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install goreleaser
run: |
# see: https://goreleaser.com/install/
brew install goreleaser
- name: Create release using goreleaser
run: |
# see: https://goreleaser.com/quick-start/
goreleaser release
33 changes: 33 additions & 0 deletions .gorelease.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# see: https://goreleaser.com
before:
hooks:
- go mod tidy
builds:
- env:
- CGO_ENABLED=0
# https://goreleaser.com/customization/build/
id: sgi
binary: sgi
goos:
- linux
- windows
- darwin
ldflags:
- -X main.revision={{.ShortCommit}} -X main.version={{.Tag}}
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
28 changes: 28 additions & 0 deletions _tools/scripts/tag_push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
#
# Description:
# Add a new tag and push it to origin
#
# Usage:
# bash tag_push.sh 0.1.4
#
set -euo pipefail

# No arguments
if [[ "$#" = 0 ]]; then
echo "You need to give 1 argument as a new tag version."
echo "e.g.) bash tag_push.sh 0.1.4"
exit 1
fi

# Wrong arguments
if [[ ! "$1" =~ "v"?([0-9]\.[0-9]\.[0-9]) ]]; then
echo "new tag version $1 is not correct."
echo "please follow the semantic versioning rule (e.g. 0.1.4 or v0.1.4)"
exit 1
fi

# add tag
git tag "v${BASH_REMATCH[1]}"
# push tag
git push origin --tag
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import (
"github.com/android-project-46group/sgi-cli/util"
)

const version = "0.1.0"

var (
version = "0.1.0"
revision = "HEAD"
)

Expand Down

0 comments on commit 0c55c75

Please sign in to comment.