Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TCN-667 add release action #70

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/release.yaml
@@ -0,0 +1,75 @@
name: Release
on:
workflow_dispatch:
inputs:
version:
type: string
description: The version you intend to release (eg x.y.z)
elliotmjackson marked this conversation as resolved.
Show resolved Hide resolved
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
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
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