Skip to content

Commit

Permalink
ci: upload binaries to releases, and update all actions to use node 20
Browse files Browse the repository at this point in the history
fix #51
  • Loading branch information
Jamalam360 committed Mar 27, 2024
1 parent ad5ebbc commit 515290e
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 52 deletions.
30 changes: 20 additions & 10 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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
20 changes: 15 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: CI

on:
push:
branches:
- '**'
pull_request:

jobs:
Expand All @@ -13,33 +15,39 @@ 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

package-vscode:
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
Expand All @@ -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
76 changes: 39 additions & 37 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -79,63 +80,64 @@ 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
contents: write

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 }}

0 comments on commit 515290e

Please sign in to comment.