Skip to content

Commit

Permalink
TCN-667 add release action (#70)
Browse files Browse the repository at this point in the history
```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)
  • Loading branch information
elliotmjackson authored Nov 8, 2022
1 parent 43eec1e commit a8ba580
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 4 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Release
on:
workflow_dispatch:
inputs:
version:
type: string
description: The version you intend to release (eg x.y.z)
required: true

env:
VERSION: v${{ github.event.inputs.version }}
APP_ID: 257262

jobs:
prepare:
runs-on: ubuntu-latest
steps:
- name: Generate token
id: generate_token
uses: tibdex/github-app-token@v1
with:
app_id: ${{env.APP_ID}}
private_key: ${{ secrets.TOKEN_EXCHANGE_GH_APP_PRIVATE_KEY }}
repository: ${{ github.repository }}
permissions: >-
{"contents": "write", "pull_requests": "write"}
- name: Checkout repository code
uses: actions/checkout@v3
with:
token: ${{ steps.generate_token.outputs.token }}
- uses: actions/setup-go@v3
with:
go-version: '^1.19.x'
- name: Update docs Version
run: make updateversion VERSION=${{env.VERSION}}
- name: Create PR
id: cpr
uses: peter-evans/create-pull-request@ad43dccb4d726ca8514126628bec209b8354b6dd
with:
add-paths: .
commit-message: "Update version to ${{env.VERSION}}"
branch: release/${{env.VERSION}}
delete-branch: true
title: "Release ${{env.VERSION}}"
body: Release prepared for ${{env.VERSION}}
token: ${{ steps.generate_token.outputs.token }}
tag:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release') }}
steps:
- name: Generate token
id: generate_token
uses: tibdex/github-app-token@v1
with:
app_id: ${{env.APP_ID}}
private_key: ${{ secrets.TOKEN_EXCHANGE_GH_APP_PRIVATE_KEY }}
repository: ${{ github.repository }}
permissions: >-
{"contents": "write"}
- name: Set VERSION variable from tag
run: |
VERSION=${{github.head_ref}}
echo "VERSION=${VERSION##*/}" >> $GITHUB_ENV
- name: Checkout repository code
uses: actions/checkout@v3
with:
token: ${{ steps.generate_token.outputs.token }}
fetch-depth: 0
- name: Tag Release
run: |
git config --global user.password ${{ steps.generate_token.outputs.token }}
git tag -d ${{env.VERSION}} 2> /dev/null || echo 'local ref does not exist'
git push origin :${{env.VERSION}} 2> /dev/null || echo 'remote ref does not exist'
git tag ${{env.VERSION}}
git push origin ${{env.VERSION}}
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ ifndef VERSION
$(error "VERSION must be set")
endif
$(SED_I) "s/default: '[0-9].[0-9][0-9]*\.[0-9][0-9]*[-rc0-9]*'/default: '$(VERSION)'/g" action.yml
$(SED_I) "s/[0-9].[0-9][0-9]*\.[0-9][0-9]*[-rc0-9]*/$(VERSION)/g" README.md

.PHONY: generate
generate: $(BIN)/license-header ## Regenerate licenses
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ steps:
You can configure `buf-setup-action` with these parameters:

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

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

Expand Down

0 comments on commit a8ba580

Please sign in to comment.