Stable Plugin Release #2
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
| # This workflow downloads the plugin archive from an existing stable release | |
| # and deploys it to gh-pages under plugins/<version>/. | |
| # | |
| # Triggered by pushing a version tag of the form <major>.<minor>.<patch>, | |
| # e.g. git tag 2.25.0 && git push origin 2.25.0 | |
| # Can also be triggered manually via workflow_dispatch with a version input. | |
| # | |
| # See: https://github.com/AAVSO/VStar/issues/589 | |
| name: Stable Plugin Release | |
| on: | |
| push: | |
| tags: | |
| - '[0-9]+.[0-9]+.[0-9]+' | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version tag to build and deploy (e.g. 2.25.0)' | |
| required: true | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| name: Stable plugin release | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Get version | |
| id: version | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| echo "version=${{ inputs.version }}" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "version=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Download plugin archive from release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: gh release download ${{ steps.version.outputs.version }} --repo ${{ github.repository }} --pattern "vstar-plugins-*.zip" | |
| - name: Checkout gh-pages | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: gh-pages | |
| path: _site | |
| - name: Deploy plugins to gh-pages | |
| run: | | |
| VERSION=${{ steps.version.outputs.version }} | |
| mkdir -p _site/plugins/$VERSION | |
| unzip -q vstar-plugins-*.zip -d _site/plugins/$VERSION/ | |
| - name: Commit and push plugins to gh-pages | |
| working-directory: _site | |
| run: | | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git config user.name "github-actions[bot]" | |
| git add -A | |
| if git diff --cached --quiet; then | |
| echo "No plugin changes to publish." | |
| exit 0 | |
| fi | |
| git commit -m "Deploy plugins for ${{ steps.version.outputs.version }}" | |
| for i in 1 2 3; do | |
| git pull --rebase origin gh-pages && git push origin gh-pages && break | |
| echo "Push attempt $i failed, retrying in $((i * 5))s..." | |
| sleep $((i * 5)) | |
| done |