Skip to content

Commit c5eea42

Browse files
authored
setup tagpar release flow (#60)
1 parent d7ccc1b commit c5eea42

File tree

5 files changed

+118
-22
lines changed

5 files changed

+118
-22
lines changed

.github/actions/release/actions.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: release
2+
description: release executables
3+
4+
inputs:
5+
tag:
6+
description: check out the tag if not empty
7+
default: ''
8+
token:
9+
description: GitHub token
10+
required: true
11+
12+
runs:
13+
using: composite
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
name: "checkout tag ${{ inputs.tag }}"
18+
if: "inputs.tag != ''"
19+
with:
20+
ref: refs/tags/${{ inputs.tag }}
21+
env:
22+
GITHUB_TOKEN: ${{ inputs.token }}
23+
- name: Set up QEMU for cross-platform image build
24+
uses: docker/setup-qemu-action@v2
25+
- name: Set up Go
26+
uses: actions/setup-go@v2
27+
with:
28+
go-version: ~1.19
29+
- name: Login to GitHub Container Registry
30+
uses: docker/login-action@v2
31+
with:
32+
registry: ghcr.io
33+
username: pfnet-research
34+
password: ${{ inputs.token }}
35+
- name: Run GoReleaser
36+
uses: goreleaser/goreleaser-action@v3
37+
with:
38+
version: v1.11.5
39+
args: release --rm-dist
40+
env:
41+
GITHUB_TOKEN: ${{ inputs.token }}

.github/workflows/release.yml

+7-19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
name: Release
1+
#
2+
# This workflow runs when tagged manually.
3+
# It would be useful when tagpr workflow failed in some reason.
4+
#
5+
name: Release By Tagged Manually
26

37
on:
48
push:
@@ -8,23 +12,7 @@ jobs:
812
run:
913
runs-on: ubuntu-latest
1014
steps:
11-
- name: Set up QEMU
12-
uses: docker/setup-qemu-action@v2
1315
- uses: actions/checkout@v3
14-
- name: Set up Go
15-
uses: actions/setup-go@v2
16+
- uses: ./.github/actions/release
1617
with:
17-
go-version: ~1.19
18-
- name: Login to GitHub Container Registry
19-
uses: docker/login-action@v2
20-
with:
21-
registry: ghcr.io
22-
username: pfnet-research
23-
password: ${{ secrets.GITHUB_TOKEN }}
24-
- name: Run GoReleaser
25-
uses: goreleaser/goreleaser-action@v3
26-
with:
27-
version: v1.11.5
28-
args: release --rm-dist --debug
29-
env:
30-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/tagpr.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#
2+
# tagpr master workflow
3+
#
4+
name: tagpr
5+
on:
6+
push:
7+
branches: ["master"]
8+
9+
jobs:
10+
tagpr:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- id: tagpr
15+
name: Tagpr
16+
uses: Songmu/tagpr@master
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
20+
# If tagpr pushed tags, invoke release custom action manually.
21+
# It is because:
22+
# > When you use the repository's GITHUB_TOKEN to perform tasks,
23+
# > events triggered by the GITHUB_TOKEN, with the exception of
24+
# > workflow_dispatch and repository_dispatch, will not create
25+
# > a new workflow run.
26+
# ref: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow
27+
- name: "Release (only when tagged)"
28+
uses: ./.github/actions/release
29+
if: "steps.tagpr.outputs.tag != ''"
30+
with:
31+
tag: ${{ steps.tagpr.outputs.tag }}
32+
token: ${{ secrets.GITHUB_TOKEN }}

.tagpr

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# config file for the tagpr in git config format
2+
# The tagpr generates the initial configuration, which you can rewrite to suit your environment.
3+
# CONFIGURATIONS:
4+
# tagpr.releaseBranch
5+
# Generally, it is "main." It is the branch for releases. The pcpr tracks this branch,
6+
# creates or updates a pull request as a release candidate, or tags when they are merged.
7+
#
8+
# tagpr.versionFile
9+
# Versioning file containing the semantic version needed to be updated at release.
10+
# It will be synchronized with the "git tag".
11+
# Often this is a meta-information file such as gemspec, setup.cfg, package.json, etc.
12+
# Sometimes the source code file, such as version.go or Bar.pm, is used.
13+
# If you do not want to use versioning files but only git tags, specify the "-" string here.
14+
# You can specify multiple version files by comma separated strings.
15+
#
16+
# tagpr.vPrefix
17+
# Flag whether or not v-prefix is added to semver when git tagging. (e.g. v1.2.3 if true)
18+
# This is only a tagging convention, not how it is described in the version file.
19+
#
20+
# tagpr.changelog (Optional)
21+
# Flag whether or not changelog is added or changed during the release.
22+
#
23+
# tagpr.command (Optional)
24+
# Command to change files just before release.
25+
#
26+
# tagpr.tmplate (Optional)
27+
# Pull request template in go template format
28+
#
29+
# tagpr.release (Optional)
30+
# GitHub Release creation behavior after tagging [true, draft, false]
31+
# If this value is not set, the release is to be created.
32+
[tagpr]
33+
vPrefix = true
34+
releaseBranch = master
35+
versionFile = -
36+
changelog = false

README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,9 @@ $ godoc -http=:6060 # access http://localhost:6060 in browser
9797
4. Push to the branch (`git push origin my-new-feature`)
9898
5. Create new [Pull Request](../../pull/new/master)
9999

100-
## Release Procedure
100+
## Release
101101

102-
1. Add a semver tag (v[0-9]+.[0-9]+.[0-9]+.) on github
103-
2. The release workflow will start automatically
102+
Release flow is fully automated. All the maintainer need to do is just to approve and merge [the next release PR](https://github.com/pfnet-research/git-ghost/pulls?q=is%3Apr+is%3Aopen+label%3Atagpr+)
104103

105104
## Copyright
106105

0 commit comments

Comments
 (0)