cuda: add ptx and sass syntax highlighting files #382
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: Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - master | |
| workflow_dispatch: | |
| inputs: | |
| create_release: | |
| description: 'Create new release' | |
| required: true | |
| type: boolean | |
| custom_tag: | |
| description: 'Pre-release tag name' | |
| required: false | |
| type: string | |
| permissions: | |
| contents: write # for creating release | |
| env: | |
| BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
| jobs: | |
| determine-tag: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| tag_name: ${{ steps.tag.outputs.name }} | |
| steps: | |
| - name: Checkout with full history | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Determine tag name | |
| id: tag | |
| shell: bash | |
| run: | | |
| BUILD_NUMBER=$(git rev-list --count HEAD) | |
| SHORT_HASH=$(git rev-parse --short=7 HEAD) | |
| CUSTOM_TAG="${{ github.event.inputs.custom_tag }}" | |
| echo "Raw values:" | |
| echo "BUILD_NUMBER: $BUILD_NUMBER" | |
| echo "SHORT_HASH: $SHORT_HASH" | |
| echo "BRANCH_NAME: ${{ env.BRANCH_NAME }}" | |
| echo "CUSTOM_TAG: $CUSTOM_TAG" | |
| # Use custom tag if provided | |
| if [[ -n "$CUSTOM_TAG" ]]; then | |
| echo "Using custom tag" | |
| TAG_NAME="${CUSTOM_TAG}" | |
| elif [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then | |
| echo "Using master branch format" | |
| TAG_NAME="b${BUILD_NUMBER}" | |
| else | |
| echo "Using non-master branch format" | |
| SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-') | |
| TAG_NAME="${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" | |
| fi | |
| echo "Final tag name: $TAG_NAME" | |
| echo "name=$TAG_NAME" >> $GITHUB_OUTPUT | |
| build: | |
| runs-on: ubuntu-latest | |
| needs: determine-tag | |
| steps: | |
| - name: Checkout with full history | |
| uses: actions/checkout@v4 | |
| #with: | |
| #fetch-depth: 0 | |
| - name: Debug Git Info | |
| id: git_info | |
| run: | | |
| echo "Current branch: ${{ env.BRANCH_NAME }}" | |
| echo "github.ref_name: ${{ github.ref_name }}" | |
| echo "github.head_ref: ${{ github.head_ref }}" | |
| BUILD_NUMBER=$(git rev-list --count HEAD) | |
| SHORT_HASH=$(git rev-parse --short=7 HEAD) | |
| echo "Build number (commit count): $BUILD_NUMBER" | |
| echo "Short hash: $SHORT_HASH" | |
| # Set for later steps | |
| echo "build_number=$BUILD_NUMBER" >> $GITHUB_ENV | |
| echo "short_hash=$SHORT_HASH" >> $GITHUB_ENV | |
| - name: Test output | |
| run: | | |
| echo "The tag name is: ${{ needs.determine-tag.outputs.tag_name }}" | |
| # Create a test file | |
| echo "Test content" > test-file.txt | |
| # Create a zip file with the tag name | |
| zip -r llama-${{ needs.determine-tag.outputs.tag_name }}-test.zip test-file.txt | |
| # List the zip file to verify name | |
| ls -la *.zip | |
| - name: Upload test artifact | |
| if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: llama-${{ needs.determine-tag.outputs.tag_name }}-test | |
| path: llama-${{ needs.determine-tag.outputs.tag_name }}-test.zip | |
| release: | |
| if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} | |
| runs-on: ubuntu-latest | |
| needs: | |
| - determine-tag | |
| - build | |
| steps: | |
| - name: Clone | |
| id: checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: ccache | |
| uses: hendrikmuhs/[email protected] | |
| with: | |
| key: release | |
| evict-old-files: 1d | |
| # Downloads all the artifacts from the previous jobs | |
| - name: Download artifacts | |
| id: download-artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ./artifact | |
| - name: Move artifacts | |
| id: move_artifacts | |
| run: mkdir -p ./artifact/release && mv ./artifact/*/*.zip ./artifact/release | |
| - name: Create release | |
| id: create_release | |
| uses: ggml-org/action-create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ needs.determine-tag.outputs.tag_name }} | |
| prerelease: ${{ github.event.inputs.custom_tag != '' }} | |
| - name: Upload release | |
| id: upload_release | |
| uses: actions/github-script@v3 | |
| with: | |
| github-token: ${{secrets.GITHUB_TOKEN}} | |
| script: | | |
| const path = require('path'); | |
| const fs = require('fs'); | |
| const release_id = '${{ steps.create_release.outputs.id }}'; | |
| for (let file of await fs.readdirSync('./artifact/release')) { | |
| if (path.extname(file) === '.zip') { | |
| console.log('uploadReleaseAsset', file); | |
| await github.repos.uploadReleaseAsset({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| release_id: release_id, | |
| name: file, | |
| data: await fs.readFileSync(`./artifact/release/${file}`) | |
| }); | |
| } | |
| } |