Skip to content

Commit a8ba580

Browse files
authoredNov 8, 2022
TCN-667 add release action (#70)
```sh cd "${BUFBUILD_BUF_SETUP_ACTION_DIR}" git switch main git pull origin main make updateversion VERSION=${VERSION} git diff git checkout -b release/v${VERSION} git commit -am "Update to v${VERSION}" git push origin release/v${VERSION} # Get that PR approved and merged git switch main git pull origin main git tag -a "v${VERSION}" -m "v${VERSION}" git push origin "v${VERSION}" ``` Resolves [TCN-680](https://linear.app/bufbuild/issue/TCN-680)
1 parent 43eec1e commit a8ba580

File tree

3 files changed

+80
-4
lines changed

3 files changed

+80
-4
lines changed
 

‎.github/workflows/release.yaml

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Release
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
version:
6+
type: string
7+
description: The version you intend to release (eg x.y.z)
8+
required: true
9+
10+
env:
11+
VERSION: v${{ github.event.inputs.version }}
12+
APP_ID: 257262
13+
14+
jobs:
15+
prepare:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Generate token
19+
id: generate_token
20+
uses: tibdex/github-app-token@v1
21+
with:
22+
app_id: ${{env.APP_ID}}
23+
private_key: ${{ secrets.TOKEN_EXCHANGE_GH_APP_PRIVATE_KEY }}
24+
repository: ${{ github.repository }}
25+
permissions: >-
26+
{"contents": "write", "pull_requests": "write"}
27+
- name: Checkout repository code
28+
uses: actions/checkout@v3
29+
with:
30+
token: ${{ steps.generate_token.outputs.token }}
31+
- uses: actions/setup-go@v3
32+
with:
33+
go-version: '^1.19.x'
34+
- name: Update docs Version
35+
run: make updateversion VERSION=${{env.VERSION}}
36+
- name: Create PR
37+
id: cpr
38+
uses: peter-evans/create-pull-request@ad43dccb4d726ca8514126628bec209b8354b6dd
39+
with:
40+
add-paths: .
41+
commit-message: "Update version to ${{env.VERSION}}"
42+
branch: release/${{env.VERSION}}
43+
delete-branch: true
44+
title: "Release ${{env.VERSION}}"
45+
body: Release prepared for ${{env.VERSION}}
46+
token: ${{ steps.generate_token.outputs.token }}
47+
tag:
48+
runs-on: ubuntu-latest
49+
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release') }}
50+
steps:
51+
- name: Generate token
52+
id: generate_token
53+
uses: tibdex/github-app-token@v1
54+
with:
55+
app_id: ${{env.APP_ID}}
56+
private_key: ${{ secrets.TOKEN_EXCHANGE_GH_APP_PRIVATE_KEY }}
57+
repository: ${{ github.repository }}
58+
permissions: >-
59+
{"contents": "write"}
60+
- name: Set VERSION variable from tag
61+
run: |
62+
VERSION=${{github.head_ref}}
63+
echo "VERSION=${VERSION##*/}" >> $GITHUB_ENV
64+
- name: Checkout repository code
65+
uses: actions/checkout@v3
66+
with:
67+
token: ${{ steps.generate_token.outputs.token }}
68+
fetch-depth: 0
69+
- name: Tag Release
70+
run: |
71+
git config --global user.password ${{ steps.generate_token.outputs.token }}
72+
git tag -d ${{env.VERSION}} 2> /dev/null || echo 'local ref does not exist'
73+
git push origin :${{env.VERSION}} 2> /dev/null || echo 'remote ref does not exist'
74+
git tag ${{env.VERSION}}
75+
git push origin ${{env.VERSION}}

‎Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ ifndef VERSION
4040
$(error "VERSION must be set")
4141
endif
4242
$(SED_I) "s/default: '[0-9].[0-9][0-9]*\.[0-9][0-9]*[-rc0-9]*'/default: '$(VERSION)'/g" action.yml
43+
$(SED_I) "s/[0-9].[0-9][0-9]*\.[0-9][0-9]*[-rc0-9]*/$(VERSION)/g" README.md
4344

4445
.PHONY: generate
4546
generate: $(BIN)/license-header ## Regenerate licenses

‎README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ steps:
2828
2929
You can configure `buf-setup-action` with these parameters:
3030

31-
Parameter | Description | Default
32-
:---------|:------------|:-------
33-
`version` | The version of the [`buf` CLI][buf-cli] to install | [`1.9.0`][version]
34-
`github_token` | The GitHub token to use when making API requests |
31+
| Parameter | Description | Default |
32+
|:---------------|:---------------------------------------------------|:-------------------|
33+
| `version` | The version of the [`buf` CLI][buf-cli] to install | [`1.9.0`][version] |
34+
| `github_token` | The GitHub token to use when making API requests | |
3535

3636
> These parameters are derived from [`action.yml`](./action.yml).
3737

0 commit comments

Comments
 (0)
Please sign in to comment.