diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 0613099..29e05f4 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -8,35 +8,45 @@ inputs: secret: description: GitHub Token required: true - + rust-target: + description: Target to install using rustup, or nothing for a default target + required: false outputs: cache-key: description: Cache key - value: ${{inputs.kind}}-${{runner.os}}-${{steps.toolchain.outputs.cachekey}} + value: ${{ inputs.kind }}-${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }} runs: using: composite steps: - - name: Setup wasm-pack - uses: jetli/wasm-pack-action@v0.4.0 - with: - version: latest + - name: Install Wasmpack + shell: bash + run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + - name: Setup Node - uses: actions/setup-node@v3 - with: + uses: actions/setup-node@v4 + with: node-version: 16 cache: npm cache-dependency-path: vscode/package-lock.json + - name: NPM Install shell: bash working-directory: vscode run: npm install + - name: Setup Task - uses: arduino/setup-task@v1 + uses: arduino/setup-task@v2 with: repo-token: ${{ inputs.secret }} + + - name: Install Rust Target + shell: bash + if: ${{ inputs.rust-target }} + run: rustup target add ${{ inputs.rust-target }} + - name: Set up cache uses: Swatinem/rust-cache@v2 with: - shared-key: ${{inputs.kind}}-${{runner.os}}-${{steps.toolchain.outputs.cachekey}} + shared-key: ${{ inputs.kind }}-${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }} workspaces: language-server diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1267d63..1a7b195 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,8 @@ name: CI on: push: + branches: + - '**' pull_request: jobs: @@ -13,15 +15,18 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest] steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 + - name: Setup uses: ./.github/actions/setup with: kind: check secret: ${{ secrets.GITHUB_TOKEN }} + - name: Format and Lint if: contains(matrix.os, 'ubuntu') run: task fmt-and-lint + - name: Cargo Check run: cargo check @@ -29,17 +34,20 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 + - name: Setup uses: ./.github/actions/setup with: kind: package-vscode secret: ${{ secrets.GITHUB_TOKEN }} + - name: Package Extension working-directory: vscode run: npm run package + - name: Upload Extension - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: pest-vscode path: vscode/pest.vsix @@ -48,12 +56,14 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 + - name: Package Sublime Text Package working-directory: sublime-text run: zip pest.sublime-package * + - name: Upload Extension - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: pest-sublime-text path: sublime-text/pest.sublime-package diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8be9f0b..b75fd83 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,10 +14,11 @@ jobs: # Allows creation of releases contents: write outputs: - release_upload_url: ${{ steps.create_release.outputs.upload_url }} + release_id: ${{ steps.create_release.outputs.id }} steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 + - name: Setup uses: ./.github/actions/setup with: @@ -62,12 +63,12 @@ jobs: - name: Create Release id: create_release - uses: actions/create-release@v1 + uses: softprops/action-gh-release@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ github.ref }} - release_name: ${{ github.ref }} + name: ${{ github.ref_name }} body: | # Checklist Before Publishing @@ -79,18 +80,13 @@ jobs: ${{ steps.get_changelog.outputs.COMMITS }} draft: true prerelease: false - - - uses: xresloader/upload-to-github-release@main - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - file: "vscode/pest.vsix;sublime-text/pest.sublime-package" - release_id: ${{ steps.create_release.outputs.id }} - overwrite: true + files: | + vscode/pest.vsix + sublime-text/pest.sublime-package build-binaries: needs: release - runs-on: ubuntu-latest + runs-on: ${{ matrix.target.runner }} permissions: # So we can upload to the release @@ -98,44 +94,50 @@ jobs: strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - arch: [x86_64] + target: + [ + { runner: "macos-14", target: "aarch64-apple-darwin", os: darwin, arch: aarch64 }, # Apple silicon + { runner: "ubuntu-latest", target: "aarch64-unknown-linux-gnu", os: linux, arch: aarch64 }, + { runner: "macos-12", target: "x86_64-apple-darwin", os: darwin, arch: x86_64 }, # Intel Mac + { runner: "ubuntu-latest", target: "x86_64-pc-windows-gnu", os: windows, arch: x86_64 }, # It's trivial to cross-compile to Windows (less so for Mac) + { runner: "ubuntu-latest", target: "x86_64-unknown-linux-gnu", os: linux, arch: x86_64 }, + ] steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup uses: ./.github/actions/setup with: kind: release-compile-binaries secret: ${{ secrets.GITHUB_TOKEN }} + rust-target: ${{ matrix.target.target }} + + - name: Set up Windows + if: matrix.target.os == 'windows' + run: sudo apt-get install -y --no-install-recommends mingw-w64 musl-tools gcc-mingw-w64-x86-64-win32 + + - name: Set up aarch64 Linux + if: matrix.target.target == 'aarch64-unknown-linux-gnu' + run: | + sudo apt-get install gcc-aarch64-linux-gnu + echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV - name: Build binary - run: cargo build --release --target=$TARGET + run: cargo build --release --target=${{ matrix.target.target }} - - name: Package binary - run: tar -czvf pest-lsp-${{ matrix.os }}-${{ matrix.arch }}.tar.gz -C target/$TARGET/release/* + - name: Package binary (Linux and Mac) + if: matrix.target.os != 'windows' + run: tar -zcvf pest-language-server-${{ matrix.target.os }}-${{ matrix.target.arch }}.tar.gz -C target/${{ matrix.target.target }}/release pest-language-server - - name: Create release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.event.release.tag_name }} - release_name: ${{ github.event.release.tag_name }} - body: | - Release ${{ github.event.release.tag_name }} - draft: false - prerelease: false + - name: Package binary (Windows) + if: matrix.target.os == 'windows' + run: tar -zcvf pest-language-server-${{ matrix.target.os }}-${{ matrix.target.arch }}.tar.gz -C target/${{ matrix.target.target }}/release pest-language-server.exe - - name: Upload release asset - uses: actions/upload-release-asset@v1 + - uses: xresloader/upload-to-github-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - upload_url: ${{ jobs.release.outputs.release_upload_url }} - asset_path: ./pest-language-server-${{ matrix.os }}-${{ matrix.arch }}.tar.gz - asset_name: pest-language-server-${{ matrix.os }}-${{ matrix.arch }}.tar.gz - asset_content_type: application/gzip + file: "./pest-language-server-${{ matrix.target.os }}-${{ matrix.target.arch }}.tar.gz" + release_id: ${{ needs.release.outputs.release_id }}