Skip to content

Commit

Permalink
Upload ZLS artifacts to our own servers
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperAuguste committed Oct 1, 2023
1 parent 5973239 commit 3c270d4
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 31 deletions.
80 changes: 50 additions & 30 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,102 +35,122 @@ jobs:
with:
version: master

- run: zig version
- name: Get Zig version
id: zig_version
run: echo "zig_version=$(zig version)" >> $GITHUB_OUTPUT

- run: zig env

- name: Build
run: zig build

- name: Build with Tracy
if: ${{ matrix.os != 'macos-latest' && github.event.inputs.bypass_tracy_and_artifacts != 'true' }}
run: zig build -Denable_tracy
- name: Get ZLS version and mimimum build version
id: zls_version
run: |
echo "zls_version=$(./zig-out/bin/zls --version)" >> $GITHUB_OUTPUT
echo "zls_minimum_build_version=$(./zig-out/bin/zls --minimum-build-version)" >> $GITHUB_OUTPUT
- name: Run Tests
run: zig build test

- name: Build artifacts
if: ${{ matrix.os == 'ubuntu-latest' && github.event.inputs.bypass_tracy_and_artifacts != 'true' }}
run: |
declare -a targets=("x86_64-windows" "x86_64-linux" "x86_64-macos" "x86-windows" "x86-linux" "aarch64-linux" "aarch64-macos" "wasm32-wasi")
mkdir -p "artifacts/"
declare -a targets=("x86_64-windows" "x86_64-linux")
# "x86_64-macos" "x86-windows" "x86-linux" "aarch64-linux" "aarch64-macos" "wasm32-wasi"
mkdir -p "artifacts/${{ steps.zls_version.outputs.zls_version }}/"
for target in "${targets[@]}"; do
mkdir -p artifacts/$target
mkdir -p artifacts/${{ steps.zls_version.outputs.zls_version }}/$target
echo "Building target ${target}..."
if [ "${GITHUB_REF##*/}" == "master" ]; then
echo "Building safe"
zig build -Dtarget=${target} -Dcpu=baseline -Doptimize=ReleaseSafe --prefix artifacts/${target}/
zig build -Dtarget=${target} -Dcpu=baseline -Doptimize=ReleaseSafe --prefix artifacts/${{ steps.zls_version.outputs.zls_version }}/${target}/
else
echo "Building debug as action is not running on master"
zig build -Dtarget=${target} -Dcpu=baseline --prefix artifacts/${target}/
zig build -Dtarget=${target} -Dcpu=baseline --prefix artifacts/${{ steps.zls_version.outputs.zls_version }}/${target}/
fi
sed -e '1,5d' < README.md > artifacts/${target}/README.md
cp LICENSE artifacts/${target}/
mv artifacts/${{ steps.zls_version.outputs.zls_version }}/${target}/bin/* artifacts/${{ steps.zls_version.outputs.zls_version }}/${target}
rmdir artifacts/${{ steps.zls_version.outputs.zls_version }}/${target}/bin
done
wget https://zigtools-releases.nyc3.digitaloceanspaces.com/zls/index.json
cp index.json artifacts/old-index.json
jq --arg targets "${targets[*]}" '.latest = "${{ steps.zls_version.outputs.zls_version }}" | .versions["${{ steps.zls_version.outputs.zls_version }}"] = {
"date": now | todateiso8601,
"builtWithZigVersion": "${{ steps.zig_version.outputs.zig_version }}",
"zlsVersion": "${{ steps.zls_version.outputs.zls_version }}",
"zlsMinimumBuildVersion": "${{ steps.zls_version.outputs.zls_minimum_build_version }}",
"commit": "${{ github.sha }}",
"targets": ($targets / " "),
}' index.json > artifacts/index.json
- name: Upload x86_64-windows artifact
if: ${{ matrix.os == 'ubuntu-latest' && github.event.inputs.bypass_tracy_and_artifacts != 'true' }}
uses: actions/upload-artifact@v3
with:
name: zls-x86_64-windows
path: artifacts/x86_64-windows/
path: artifacts/${{ steps.zls_version.outputs.zls_version }}/x86_64-windows/

- name: Upload x86_64-linux artifact
if: ${{ matrix.os == 'ubuntu-latest' && github.event.inputs.bypass_tracy_and_artifacts != 'true' }}
uses: actions/upload-artifact@v3
with:
name: zls-x86_64-linux
path: artifacts/x86_64-linux/
path: artifacts/${{ steps.zls_version.outputs.zls_version }}/x86_64-linux/

- name: Upload x86_64-macos artifact
if: ${{ matrix.os == 'ubuntu-latest' && github.event.inputs.bypass_tracy_and_artifacts != 'true' }}
uses: actions/upload-artifact@v3
with:
name: zls-x86_64-macos
path: artifacts/x86_64-macos/
path: artifacts/${{ steps.zls_version.outputs.zls_version }}/x86_64-macos/

- name: Upload x86-windows artifact
if: ${{ matrix.os == 'ubuntu-latest' && github.event.inputs.bypass_tracy_and_artifacts != 'true' }}
uses: actions/upload-artifact@v3
with:
name: zls-x86-windows
path: artifacts/x86-windows/
path: artifacts/${{ steps.zls_version.outputs.zls_version }}/x86-windows/

- name: Upload x86-linux artifact
if: ${{ matrix.os == 'ubuntu-latest' && github.event.inputs.bypass_tracy_and_artifacts != 'true' }}
uses: actions/upload-artifact@v3
with:
name: zls-x86-linux
path: artifacts/x86-linux/
path: artifacts/${{ steps.zls_version.outputs.zls_version }}/x86-linux/

- name: Upload aarch64-linux artifact
if: ${{ matrix.os == 'ubuntu-latest' && github.event.inputs.bypass_tracy_and_artifacts != 'true' }}
uses: actions/upload-artifact@v3
with:
name: zls-aarch64-linux
path: artifacts/aarch64-linux/
path: artifacts/${{ steps.zls_version.outputs.zls_version }}/aarch64-linux/

- name: Upload aarch64-macos artifact
if: ${{ matrix.os == 'ubuntu-latest' && github.event.inputs.bypass_tracy_and_artifacts != 'true' }}
uses: actions/upload-artifact@v3
with:
name: zls-aarch64-macos
path: artifacts/aarch64-macos/
path: artifacts/${{ steps.zls_version.outputs.zls_version }}/aarch64-macos/

- name: Upload wasm32-wasi artifact
if: ${{ matrix.os == 'ubuntu-latest' && github.event.inputs.bypass_tracy_and_artifacts != 'true' }}
uses: actions/upload-artifact@v3
with:
name: zls-wasm32-wasi
path: artifacts/wasm32-wasi/

- name: Beam to Felix
if: ${{ matrix.os == 'ubuntu-latest' && github.ref == 'refs/heads/master' && github.repository_owner == 'zigtools' }}
uses: easingthemes/[email protected]
env:
SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_PRIVKEY }}
ARGS: "-rltgoDzvO --delete"
SOURCE: "artifacts/"
REMOTE_HOST: ${{ secrets.WEBSITE_DEPLOY_HOST }}
REMOTE_USER: ${{ secrets.WEBSITE_DEPLOY_USER }}
TARGET: ${{ secrets.WEBSITE_DEPLOY_FOLDER }}
path: artifacts/${{ steps.zls_version.outputs.zls_version }}/wasm32-wasi/

- uses: BetaHuhn/do-spaces-action@v2
if: ${{ matrix.os == 'ubuntu-latest' && github.ref == 'refs/heads/master' }}
with:
access_key: ${{ secrets.DO_SPACES_ACCESS_KEY }}
secret_key: ${{ secrets.DO_SPACES_SECRET_KEY }}
space_name: zigtools-releases
space_region: nyc3
source: artifacts/
out_dir: zls/
4 changes: 3 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ const std = @import("std");
const builtin = @import("builtin");

const zls_version = std.SemanticVersion{ .major = 0, .minor = 12, .patch = 0 };
const min_zig_string = "0.12.0-dev.654+599641357";

pub fn build(b: *std.build.Builder) !void {
comptime {
const current_zig = builtin.zig_version;
const min_zig = std.SemanticVersion.parse("0.12.0-dev.654+599641357") catch unreachable; // std.http: introduce options to http client to allow for raw uris
const min_zig = std.SemanticVersion.parse(min_zig_string) catch unreachable; // std.http: introduce options to http client to allow for raw uris
if (current_zig.order(min_zig) == .lt) {
@compileError(std.fmt.comptimePrint("Your Zig version v{} does not meet the minimum build requirement of v{}", .{ current_zig, min_zig }));
}
Expand Down Expand Up @@ -81,6 +82,7 @@ pub fn build(b: *std.build.Builder) !void {
}
};
exe_options.addOption([]const u8, "version_string", version_string);
exe_options.addOption([]const u8, "min_zig_string", min_zig_string);

const version = try std.SemanticVersion.parse(version_string);
exe_options.addOption(std.SemanticVersion, "version", version);
Expand Down
7 changes: 7 additions & 0 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ fn parseArgs(allocator: std.mem.Allocator) !ParseArgsResult {
const ArgId = enum {
help,
version,
@"minimum-build-version",
@"compiler-version",
replay,
@"enable-debug-log",
Expand All @@ -150,6 +151,7 @@ fn parseArgs(allocator: std.mem.Allocator) !ParseArgsResult {
var cmd_infos: InfoMap = InfoMap.init(.{
.help = "Prints this message.",
.version = "Prints the version.",
.@"minimum-build-version" = "Prints the minimum build version specified in build.zig.",
.@"compiler-version" = "Prints the compiler version with which the server was compiled.",
.replay = "Replay a previous recorded zls session",
.@"enable-debug-log" = "Enables debug logs.",
Expand Down Expand Up @@ -200,6 +202,7 @@ fn parseArgs(allocator: std.mem.Allocator) !ParseArgsResult {
switch (id) {
.help,
.version,
.@"minimum-build-version",
.@"compiler-version",
.@"enable-debug-log",
.@"enable-message-tracing",
Expand All @@ -226,6 +229,10 @@ fn parseArgs(allocator: std.mem.Allocator) !ParseArgsResult {
try stdout.writeAll(build_options.version_string ++ "\n");
return result;
}
if (specified.get(.@"minimum-build-version")) {
try stdout.writeAll(build_options.min_zig_string ++ "\n");
return result;
}
if (specified.get(.@"compiler-version")) {
try stdout.writeAll(zig_builtin.zig_version_string ++ "\n");
return result;
Expand Down

0 comments on commit 3c270d4

Please sign in to comment.