ci: Generate Registry Docs #36
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: Release | ||
on: | ||
push: | ||
branches: | ||
- main | ||
permissions: | ||
contents: read | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: ^1.17 | ||
cache: false | ||
- name: Run Lint | ||
uses: golangci/golangci-lint-action@v3 | ||
codespell: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.8 | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install codespell | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
- name: Check spelling with codespell | ||
run: codespell --ignore-words=codespell.txt || exit 1 | ||
unit_test: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, macos-latest] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ^1.17 | ||
- uses: actions/cache@v3 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Vet | ||
run: make vet | ||
- name: Test | ||
run: make test | ||
- name: Coveralls Parallel | ||
uses: coverallsapp/github-action@v2 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
flag-name: unit-go-${{ runner.os }} | ||
parallel: true | ||
path-to-lcov: ./covprofile | ||
integration_test: | ||
needs: [unit_test] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ^1.17 | ||
- uses: actions/cache@v3 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Run Integration Tests | ||
run: make testacc | ||
- name: Coveralls Parallel | ||
uses: coverallsapp/github-action@v2 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
flag-name: integration-go-${{ runner.os }} | ||
parallel: true | ||
path-to-lcov: ./covprofile | ||
coverage: | ||
needs: [unit_test, integration_test] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Upload coverage to Coveralls | ||
uses: coverallsapp/github-action@v2 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
parallel-finished: true | ||
file: ./covprofile | ||
docs: | ||
runs-on: ubuntu-latest | ||
needs: [unit_test, integration_test] | ||
permissions: | ||
contents: write | ||
outputs: | ||
changed: ${{ steps.docs.outputs.changed }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: ^1.17 | ||
- run: make docs | ||
- name: Check changes | ||
id: docs | ||
shell: bash | ||
run: | | ||
if [[ `git status --porcelain | grep "docs/"` ]]; then | ||
echo "changed=true" >> "$GITHUB_OUTPUT" | ||
else | ||
echo "changed=false" >> "$GITHUB_OUTPUT" | ||
fi | ||
- name: Push docs | ||
if: steps.docs.outputs.changed | ||
run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
git add docs/ | ||
git commit -m "docs: Generate Registry Documentation" | ||
git push | ||
release: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
needs: [lint, codespell, integration_test, docs] | ||
if: !needs.docs.outputs.changed | ||
outputs: | ||
release_created: ${{ steps.release.outputs.release_created }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: google-github-actions/release-please-action@v3 | ||
id: release | ||
with: | ||
token: ${{ secrets.DEVOPS_TOKEN }} | ||
release-type: go | ||
bootstrap-sha: 48eb0f97cddc5c2f6af991748a57c7142af15723 | ||
changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"perf","section":"Performance Improvements","hidden":false},{"type":"docs","section":"Documentation","hidden":true},{"type":"test","section":"Tests","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":false},{"type":"ci","section":"Miscellaneous","hidden":true}]' | ||
- name: Push to Release Branch | ||
if: ${{ steps.release.outputs.release_created }} | ||
uses: actions/github-script@v6 | ||
env: | ||
MAJOR_VERSION: ${{ steps.release.outputs.major }} | ||
with: | ||
github-token: ${{ secrets.DEVOPS_TOKEN }} | ||
script: | | ||
github.rest.git.updateRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: `heads/${process.env.MAJOR_VERSION}-stable`, | ||
sha: context.sha, | ||
force: true | ||
}); |