gn-language-server/.github/workflows/ci.yml
2025-11-01 10:56:53 +09:00

178 lines
5.5 KiB
YAML

# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: CI
on:
push:
branches:
- "main"
- "v*.*.x"
tags:
- "v*.*.*"
pull_request:
branches:
- "main"
- "v*.*.x"
env:
CARGO_TERM_COLOR: always
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.24.1
- uses: dtolnay/rust-toolchain@fbaa7e9cfc198f7c12d653f12beae9646e216b29 # 1.85.1
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
- run: go install github.com/google/addlicense@dc31ac9ffcca99c9457226366135701794b128c0 # v1.1.1
- run: addlicense -check .
- run: cargo fmt --check
- run: cargo clippy
- run: cargo install --force --locked cargo-deny@0.18.2
- run: cargo deny check licenses
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: npm ci
working-directory: vscode-gn
- run: npm run lint
working-directory: vscode-gn
build:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
rust_target: x86_64-unknown-linux-musl
vscode_target: linux-x64
- os: macos-latest
rust_target: aarch64-apple-darwin
vscode_target: darwin-arm64
- os: windows-latest
rust_target: x86_64-pc-windows-msvc
vscode_target: win32-x64
runs-on: ${{ matrix.os }}
env:
CARGO_BUILD_TARGET: ${{ matrix.rust_target }}
name: build (${{ matrix.vscode_target }})
steps:
- uses: actions/checkout@v4
- run: sudo apt-get install musl-tools
if: matrix.os == 'ubuntu-latest'
- uses: dtolnay/rust-toolchain@fbaa7e9cfc198f7c12d653f12beae9646e216b29 # 1.85.1
with:
targets: ${{ matrix.rust_target }}
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: npm ci
working-directory: vscode-gn
- run: npm run build
working-directory: vscode-gn
- run: npx vsce package $(if python3 ../scripts/is_prerelease.py; then echo --pre-release; fi) --target=${{ matrix.vscode_target }}
working-directory: vscode-gn
shell: bash
- uses: actions/upload-artifact@v4
with:
name: vscode-gn-vsix-${{ matrix.vscode_target }}
path: vscode-gn/*.vsix
- uses: actions/upload-artifact@v4
with:
name: gn-language-server-${{ matrix.rust_target }}
path: vscode-gn/dist/gn-language-server*
attestation:
runs-on: ubuntu-latest
permissions:
id-token: write
attestations: write
needs:
- build
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/artifacts
- uses: actions/attest-build-provenance@v3
with:
subject-path: artifacts/**
upload-release-artifacts:
runs-on: ubuntu-latest
permissions:
contents: write
needs:
- build
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: vscode-gn-vsix-*
path: ${{ github.workspace }}/artifacts
merge-multiple: true
- run: ls -l .
working-directory: artifacts
- run: gh release upload "${{ github.ref_name }}" artifacts/*
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: startsWith(github.ref, 'refs/tags/v')
publish-vscode:
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: vscode-gn-vsix-*
path: ${{ github.workspace }}/vscode-gn
merge-multiple: true
- run: ls -l *.vsix
working-directory: vscode-gn
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: npm ci
working-directory: vscode-gn
if: startsWith(github.ref, 'refs/tags/v')
- run: npx -y vsce publish --skip-duplicate $(python3 ../scripts/release_flags.py) --packagePath *.vsix
working-directory: vscode-gn
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
if: startsWith(github.ref, 'refs/tags/v')
- run: npx -y ovsx publish --pat ${{ secrets.OVSX_PAT }} $(if python3 ../scripts/is_prerelease.py; then echo --pre-release; fi) --packagePath *.vsix
working-directory: vscode-gn
if: startsWith(github.ref, 'refs/tags/v')
publish-cargo:
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@fbaa7e9cfc198f7c12d653f12beae9646e216b29 # 1.85.1
- run: if ! python3 scripts/is_prerelease.py; then cargo publish; fi
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
if: startsWith(github.ref, 'refs/tags/v')