Publish GA OAS with minor version update #134
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish GA OAS with minor version update | |
on: | |
workflow_dispatch: | |
inputs: | |
override_schedule: | |
description: "Override the release schedule?" | |
required: true | |
type: boolean | |
default: false | |
schedule: | |
- cron: '0 12 * * 3' | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
outputs: | |
should-continue: ${{ steps.checker.outputs.continue }} | |
steps: | |
- name: Check if it is first Wednesday of the month | |
id: checker | |
continue-on-error: true | |
run: | | |
if [[ `date +'%d' | sed 's/^0*//'` -le 7 ]]; then | |
echo "continue=yes" >> $GITHUB_OUTPUT | |
else | |
echo "continue=no" >> $GITHUB_OUTPUT | |
fi | |
publish: | |
needs: check | |
if: inputs.override_schedule || needs.check.outputs.should-continue == 'yes' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@master | |
with: | |
ref: "master" | |
- 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_ga.json openapi/spec2.json | |
mv openapi/oas3_ga.json openapi/spec3.json | |
rm openapi/oas*_beta.json | |
- name: Get latest GA version | |
id: current-version | |
uses: cardinalby/git-get-release-action@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
latest: true | |
prerelease: false | |
- 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/[email protected] | |
with: | |
version: ${{ steps.sanitized-prefix.outputs.SANITIZED_PREFIX }} | |
next-version-increment-minor: true | |
- name: Set new version | |
id: new-version | |
run: echo "NEW_VERSION=v${{ env.CURRENT_VERSION_MAJOR }}.${{ env.NEXT_VERSION_MINOR }}.0" >> $GITHUB_ENV | |
- name: Update OAS docs with new version | |
uses: jacobtomlinson/gha-find-replace@v2 | |
with: | |
find: '"version": "0.0.0"' | |
replace: '"version": "${{ env.CURRENT_VERSION_MAJOR }}.${{ env.NEXT_VERSION_MINOR }}.0"' | |
regex: false | |
include: openapi/* | |
- name: Commit changes | |
uses: EndBug/add-and-commit@v9 | |
with: | |
add: openapi/* | |
new_branch: "master" | |
tag: "${{ env.NEW_VERSION }}" | |
message: "API version ${{ env.NEW_VERSION }}" | |
- name: Create release | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: "${{ env.NEW_VERSION }}" | |
prerelease: false | |
artifacts: "${{ env.NEW_VERSION }}.tar.gz,${{ env.NEW_VERSION }}.zip" | |
skipIfReleaseExists: true | |
body: "API version ${{ env.NEW_VERSION }}" |