fix(ci-cd): Fix ci:cd #4
This file contains 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: Build nightly release | ||
permissions: | ||
contents: write | ||
on: | ||
release: | ||
types: [ published ] | ||
jobs: | ||
build-server: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Check git version matches flake version | ||
shell: bash | ||
run: | | ||
if ! [ $(echo '${{ github.ref }}' | cut -d'v' -f 2) = $(grep '# CI:CD-VERSION$' flake.nix | cut -d'"' -f 2) ]; | ||
then | ||
echo "Version mismatch between Git and flake" | ||
exit 1 | ||
fi | ||
- name: Check version in code matches flake version | ||
shell: bash | ||
run: | | ||
if ! [ $(grep '// CI:CD-VERSION$' server/root-handler/handler.go | cut -d'"' -f 2) = $(grep '# CI:CD-VERSION$' flake.nix | cut -d'"' -f 2) ]; | ||
then | ||
echo "Version mismatch between code and flake" | ||
exit 1 | ||
fi | ||
- name: Check vs code package.json version matches flake version | ||
shell: bash | ||
run: | | ||
if ! [ $(grep '"version": "' vs-code-extension/package.json | cut -d'"' -f 4) = $(grep '# CI:CD-VERSION$' flake.nix | cut -d'"' -f 2) ]; | ||
then | ||
echo "Version mismatch between vs code package.json and flake" | ||
exit 1 | ||
fi | ||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: stable | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v6 | ||
with: | ||
distribution: goreleaser | ||
version: "~> v2" | ||
args: release --clean | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_CONFIGLSP_TOKEN }} | ||
build-extension: | ||
name: Build extension for ${{ matrix.target }} | ||
runs-on: ${{ matrix.os }} | ||
needs: | ||
# Wait for server to build so that we know the checks have passed | ||
- build-server | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- target: x86_64-apple-darwin | ||
os: macos-latest | ||
cross: false | ||
- target: aarch64-apple-darwin | ||
os: macos-latest | ||
cross: false | ||
- target: x86_64-unknown-linux-gnu | ||
os: ubuntu-latest | ||
cross: false | ||
- target: aarch64-unknown-linux-gnu | ||
os: ubuntu-latest | ||
cross: false | ||
# - target: x86_64-pc-windows-msvc | ||
# os: windows-latest | ||
# cross: false | ||
# - target: aarch64-pc-windows-msvc | ||
# os: windows-latest | ||
# cross: false | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: cachix/install-nix-action@v27 | ||
with: | ||
github_access_token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Check Flake | ||
run: nix flake check | ||
- name: Build extension | ||
run: nix build .#"vs-code-extension" | ||
- name: Rename extension | ||
run: cp result/*.vsix $(basename result/*.vsix)-${{ matrix.target }}.vsix | ||
- uses: softprops/action-gh-release@v2 | ||
with: | ||
files: *.vsix | ||
- name: Target to vs code target | ||
id: vscode_target | ||
run: | | ||
if [ "${{ matrix.target }}" = "x86_64-apple-darwin" ]; then | ||
echo "target=darwin-x64" >> $GITHUB_OUTPUT | ||
elif [ "${{ matrix.target }}" = "aarch64-apple-darwin" ]; then | ||
echo "target=darwin-arm64" >> $GITHUB_OUTPUT | ||
elif [ "${{ matrix.target }}" = "x86_64-unknown-linux-gnu" ]; then | ||
echo "target=linux-x64" >> $GITHUB_OUTPUT | ||
elif [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then | ||
echo "target=linux-arm64" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Upload extension to VS Code Marketplace | ||
run: nix develop .#"vs-code-extension" --command bash -c "vsce publish --target ${{ steps.vscode_target.outputs.target }} --packagePath *.vsix" | ||
env: | ||
VSCE_PAT: ${{ secrets.VSCE_TOKEN }} | ||