forked from stripe/stripe-mock
-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (51 loc) · 1.83 KB
/
tag.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: Create Tag and trigger release
on:
workflow_dispatch:
inputs:
tag:
description: "Tag name, defaults to minor increment."
required: false
sha:
description: "Commit SHA to tag. Defaults to latest."
required: false
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Code checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set the commit SHA
id: sha
run: echo "::set-output name=commitSha::$(if [ -z "$SHA" ]; then echo $GITHUB_SHA; else echo $SHA; fi)"
env:
SHA: ${{ github.event.inputs.sha }}
- name: Set the tag
id: tag
run: |
last_tag="$(git describe --tags --abbrev=0)"
# Parse the version into parts, increment the minor version and reset the patch to 0
# Example:
# v1.2.3 is parsed into $1 = "v1.", $2 = "2", $3 = ".3"
# and concatenated back into v1.3.0
new_tag="$(echo "$last_tag" | perl -pe 's/^(v\d+\.)(\d+)(\.\d+)$/$1.($2+1).".0"/e')"
echo "::set-output name=newTag::$(if [ -z "$TAG" ]; then echo $new_tag; else echo $TAG; fi)"
env:
TAG: ${{ github.event.inputs.tag }}
- uses: tibdex/github-app-token@v1.5.2
id: gh-api-token
with:
app_id: ${{ secrets.GH_APP_STRIPE_OPENAPI_APP_ID }}
private_key: ${{ secrets.GH_APP_STRIPE_OPENAPI_PRIVATE_KEY }}
- name: Create tag
uses: actions/github-script@v5
with:
github-token: ${{ steps.gh-api-token.outputs.token }}
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ steps.tag.outputs.newTag }}',
sha: '${{ steps.sha.outputs.commitSha }}'
})