-
Notifications
You must be signed in to change notification settings - Fork 19
76 lines (74 loc) · 2.78 KB
/
publish-pre-release-patch-version-oas.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Publish beta OAS with patch version update
on:
workflow_dispatch:
inputs:
override_version:
description: "Override the patch version?"
required: false
type: string
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
ref: "v1-beta"
- name: Read from AWS bucket
run: |
aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }}
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws configure set region ${{ secrets.AWS_REGION }}
aws s3 sync ${{ secrets.AWS_S3_BUCKET }} ./openapi
mv openapi/oas2_beta.json openapi/spec2.json
mv openapi/oas3_beta.json openapi/spec3.json
rm openapi/oas*_ga.json
- name: Get latest pre-release version
id: current-version
uses: cardinalby/git-get-release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
latest: true
prerelease: true
- name: Strip v prefix from version
id: sanitized-prefix
run: |
CURRENT_VERSION=${{ steps.current-version.outputs.tag_name }}
VERSION_WITHOUT_V=$(echo $CURRENT_VERSION | sed -e "s/v//gI")
echo "SANITIZED_PREFIX=$VERSION_WITHOUT_V" >> $GITHUB_OUTPUT
- name: Generate next version
id: next-version
uses: HardNorth/github-version-generate@v1.3.0
with:
version: ${{ steps.sanitized-prefix.outputs.SANITIZED_PREFIX }}
next-version-increment-patch: true
- name: Set new version
id: new-version
run: |
if [ -n "${{ github.event.inputs.override_version }}" ]; then
echo "NEW_VERSION=v${{ github.event.inputs.override_version }}" >> $GITHUB_ENV
else
echo "NEW_VERSION=v${{ env.CURRENT_VERSION_MAJOR }}.${{ env.CURRENT_VERSION_MINOR }}.${{ env.NEXT_VERSION_PATCH }}-beta" >> $GITHUB_ENV
fi
- name: Update OAS docs with new version
uses: jacobtomlinson/gha-find-replace@v2
with:
find: '"version": "0.0.0"'
replace: '"version": "${{ env.NEW_VERSION }}"'
regex: false
include: openapi/*
- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
add: openapi/*
new_branch: "v1-beta"
tag: "${{ env.NEW_VERSION }}"
message: "API version ${{ env.NEW_VERSION }}"
- name: Create release
uses: ncipollo/release-action@v1
with:
tag: "${{ env.NEW_VERSION }}"
prerelease: true
artifacts: "${{ env.NEW_VERSION }}.tar.gz,${{ env.NEW_VERSION }}.zip"
skipIfReleaseExists: true
body: "API version ${{ env.NEW_VERSION }}"