| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- name: release
- on:
- workflow_dispatch:
- push:
- branches:
- - main
- jobs:
- release:
- runs-on: ubuntu-latest
- permissions: write-all
- name: Export
- steps:
- - name: Checkout
- uses: actions/checkout@v4
- with:
- fetch-depth: 0
-
- - name: Check version
- id: version-check
- run: |
- chmod +x ./scripts/is-newer-version.bash
- chmod +x ./scripts/get-version.bash
- VERSION=$(./scripts/is-newer-version.bash)
- echo "version=${VERSION}" >> $GITHUB_OUTPUT
- if [ "$VERSION" != "0" ]; then
- echo "New version detected: $VERSION"
- else
- echo "No new version to release"
- fi
- - name: Push tag
- if: steps.version-check.outputs.version != '0'
- id: push-tag
- run: |
- tag="v${{ steps.version-check.outputs.version }}"
- git config user.name "${GITHUB_ACTOR}"
- git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- git tag -a "${tag}" -m "Release ${tag}"
- git push origin "${tag}"
- echo "tag_name=${tag}" >> $GITHUB_OUTPUT
- - name: Checkout
- if: steps.version-check.outputs.version != '0'
- uses: actions/checkout@v4
- - name: Setup Rust
- if: steps.version-check.outputs.version != '0'
- uses: MatteoH2O1999/setup-rust@v1
- - name: Build project
- if: steps.version-check.outputs.version != '0'
- run: cargo build --release
- shell: bash
- working-directory: ${{ github.action_path }}
- - name: Generate minimized HTML
- if: steps.version-check.outputs.version != '0'
- run: cargo run --release -- index.html index.min.html
- shell: bash
- working-directory: ${{ github.action_path }}
- - name: Copy files
- if: steps.version-check.outputs.version != '0'
- run: |
- mkdir -p ../release
- cp -v index.html ../release/
- cp -v index.min.html ../release/
- shell: bash
- working-directory: ${{ github.action_path }}
- - name: Create release
- if: steps.version-check.outputs.version != '0'
- uses: ncipollo/release-action@v1
- with:
- generateReleaseNotes: true
- tag: "v${{ steps.version-check.outputs.version }}"
- artifacts: "../release/index.html,../release/index.min.html"
- - name: Delete tag on failure
- if: failure() && steps.push-tag.outputs.tag_name != ''
- run: |
- git config user.name "${GITHUB_ACTOR}"
- git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- git push --delete origin "${{ steps.push-tag.outputs.tag_name }}"
- git tag -d "${{ steps.push-tag.outputs.tag_name }}"
|