Merge pull request #17 from Soneso/matrix #42
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: Deploy Documentation to GitHub Pages | |
| on: | |
| push: | |
| branches: | |
| - main # Deploy on every push to main | |
| workflow_dispatch: # Allows manual trigger from GitHub Actions tab | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| # Prevent concurrent deployments | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| cache: 'gradle' | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Generate Dokka documentation | |
| run: ./gradlew :stellar-sdk:dokkaGenerateHtml --no-daemon | |
| - name: Extract version from tag | |
| id: version | |
| run: | | |
| if [ -n "${{ github.ref_name }}" ] && [[ "${{ github.ref_name }}" == v* ]]; then | |
| VERSION="${{ github.ref_name }}" | |
| VERSION="${VERSION#v}" # Remove 'v' prefix | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Detected version: $VERSION" | |
| else | |
| echo "version=latest" >> $GITHUB_OUTPUT | |
| echo "Using version: latest (manual trigger or non-tag push)" | |
| fi | |
| - name: Copy generated docs to versioned directory | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| echo "Copying Dokka output to docs/api/$VERSION" | |
| # Remove existing version directory if it exists | |
| rm -rf docs/api/$VERSION | |
| # Copy generated Dokka HTML to versioned directory | |
| mkdir -p docs/api/$VERSION | |
| cp -r stellar-sdk/build/dokka/html/* docs/api/$VERSION/ | |
| # Always update 'latest' symlink/directory | |
| rm -rf docs/api/latest | |
| mkdir -p docs/api/latest | |
| cp -r stellar-sdk/build/dokka/html/* docs/api/latest/ | |
| echo "Documentation copied to docs/api/$VERSION and docs/api/latest" | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v4 | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: 'docs' | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |