chore: add release workflow #11
This file contains hidden or 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: OpenAPI | |
| on: [push] | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| - name: Setup spectral | |
| run: npm install -g @stoplight/spectral-cli | |
| - name: Install IBM Cloud ruleset | |
| run: npm install @ibm-cloud/openapi-ruleset | |
| - name: Lint OpenAPI spec | |
| run: spectral lint docs/openapi.yaml | |
| build-html: | |
| runs-on: ubuntu-latest | |
| needs: lint | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| - name: Setup OpenAPI generator | |
| run: npm install -g @openapitools/openapi-generator-cli | |
| - name: Build HTML documentation | |
| run: openapi-generator-cli generate --generator-name html2 --input-spec docs/openapi.yaml --output dist | |
| - name: Upload HTML documentation as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: openapi-html | |
| path: dist/index.html | |
| release: | |
| name: Create Release | |
| runs-on: ubuntu-latest | |
| needs: build-html | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Validate tag format | |
| run: | | |
| TAG="${GITHUB_REF#refs/tags/}" | |
| if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "Tag $TAG does not match the required format v[0-9]+.[0-9]+.[0-9]+" | |
| exit 1 | |
| fi | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Create Release | |
| id: create_release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: docs/openapi.yaml | |
| publish: | |
| name: Publish HTML documentation | |
| runs-on: ubuntu-latest | |
| needs: build-html | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| permissions: | |
| contents: write | |
| actions: read | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| steps: | |
| - name: Download artifact from build-html job | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: openapi-html | |
| path: public | |
| - name: Deploy | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./public |