Skip to content

Commit

Permalink
Merge branch 'master' into fix/atlas-tool
Browse files Browse the repository at this point in the history
  • Loading branch information
ire4ever1190 authored Jan 23, 2024
2 parents 82115f3 + d78d740 commit b908f11
Show file tree
Hide file tree
Showing 17 changed files with 235 additions and 401 deletions.
177 changes: 108 additions & 69 deletions .github/workflows/release_build.yml
Original file line number Diff line number Diff line change
@@ -1,93 +1,132 @@
# This workflow will automatically upload a binary artifact when a release/tag is created
name: Build and upload binary

on:
# allow to build manually
on:
# allow to build manually
workflow_dispatch:
# build automatically when pushing a tag
# build automatically when pushing a tag
push:
branches:
- "!*"
tags:
- "v*"

env:
ZIG_SYSTEM_LINKER_HACK: 1

jobs:
# ----------------------------------------------------------------------------
# this will checkout and build nim stable from gh repository on manylinux2014 / CentOS 7
build-linux:
runs-on: ubuntu-latest
container:
image: quay.io/pypa/manylinux2014_x86_64
build:
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
include:
# Windows builds
- os: windows-latest
target: x86_64-windows-gnu
suffix: windows_amd64
cpu: amd64
- os: windows-latest
target: aarch64-windows-gnu
suffix: windows_arm64
cpu: arm64
# Linux builds
- os: ubuntu-latest
target: aarch64-linux-gnu
suffix: linux_arm64
cpu: arm64
- os: ubuntu-latest
target: x86_64-linux-gnu
suffix: linux_amd64
cpu: amd64
# MacOS builds
- os: macos-latest
target: aarch64-macos-none
suffix: macosx_arm64
cpu: arm64
- os: macos-latest
target: x86_64-macos-none
suffix: macosx_amd64
cpu: amd64
runs-on: ${{ matrix.os }}
name: Build ${{ matrix.target }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup Nim
uses: jiro4989/setup-nim-action@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install zig
uses: korandoru/setup-zig@v1
with:
zig-version: 0.11.0
- name: Install dependencies
run: |
nimble install -y zigcc
- name: Build proxy
run: |
nimble -y c src/choosenimpkg/proxyexe -d:zig.target="${{ matrix.target }}" --cpu:"${{ matrix.cpu }}" -d:release --opt:size
- name: Build binary
run: |
CHOOSENIM_DIR=`pwd`
# checking out and compiling nim last stable from git tag
mkdir -p nimDir
STABLE_NIM=`curl -sSL http://nim-lang.org/channels/stable | xargs`
git clone --depth 1 --branch v$STABLE_NIM https://github.com/nim-lang/Nim.git nimDir
cd nimDir
sh build_all.sh
bin/nim c koch
./koch boot -d:release
./koch tools
PATH=$PATH:`pwd`/bin
# compile choosenim
cd $CHOOSENIM_DIR
nimble install -y
nimble build
ls bin/*
nimble -y build -d:noBuildProxy -d:zig.target="${{ matrix.target }}" --cpu:"${{ matrix.cpu }}" -d:release --opt:size
- name: Update file name
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
run: mv bin/choosenim bin/choosenim-${{ github.ref_name }}_${{ matrix.suffix }}
- name: Update file name
if: ${{ matrix.os == 'windows-latest' }}
run: mv bin\choosenim.exe bin\choosenim-${{ github.ref_name }}_${{ matrix.suffix }}.exe

- name: Upload binaries to release/tag
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
overwrite: true
overwrite: true
file_glob: true
tag: ${{ github.ref }}
asset_name: choosenim-manylinux2014
file: ${{ runner.workspace }}/choosenim/bin/choosenim
file: bin/choosenim-${{ github.ref_name }}_${{ matrix.suffix }}*
- name: Upload artefacts
uses: actions/upload-artifact@v4
with:
name: choosenim-${{ github.ref_name }}_${{ matrix.suffix }}
path: bin/choosenim-${{ github.ref_name }}_${{ matrix.suffix }}*
retention-days: 1

# ----------------------------------------------------------------------------
# this uses choosenim by itself - you may need to build manually if you break choosenim
build-win32:
runs-on: windows-latest
deploy-site:
name: Deploy site
needs: build
permissions:
pages: write
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: iffy/[email protected]
- name: Build binary
run: |
nimble install -y
nimble build
dir bin/*
- name: Upload binaries to release/tag
uses: svenstaro/upload-release-action@v2
- uses: actions/checkout@v4

- name: Download workflow artifact
uses: actions/download-artifact@v4
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
overwrite: true
tag: ${{ github.ref }}
asset_name: choosenim-windows
file: ${{ runner.workspace }}/choosenim/bin/choosenim.exe
path: site/

# ----------------------------------------------------------------------------
# this uses choosenim by itself - you may need to build manually if you break choosenim
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: iffy/[email protected]
- name: Build binary
run: |
nimble install -y
nimble build
ls bin/*
- name: Upload binaries to release/tag
uses: svenstaro/upload-release-action@v2
- name: Add latest version
run: echo "${{ github.ref_name }}" >> site/stable

- name: Setup Nim
uses: jiro4989/setup-nim-action@v1
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
overwrite: true
tag: ${{ github.ref }}
asset_name: choosenim-macos
file: ${{ runner.workspace }}/choosenim/bin/choosenim
nim-version: devel
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Create index
run: nim md2html --out:site/index.html readme.md

- name: Add init script
run: mv scripts/choosenim-unix-init.sh site/init.sh

- name: Create pages artefact
uses: actions/upload-pages-artifact@v3
with:
path: site/

- name: Deploy site
uses: actions/deploy-pages@v4

52 changes: 52 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Run tests

on:
push:
branches:
- master
pull_request:

jobs:
nim-tests:
name: Nim tests
timeout-minutes: 60
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: Setup Nim
uses: jiro4989/setup-nim-action@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Can build
run: nimble -y build

- name: Run tests
run: nimble -y test

unix-test:
name: Install script test (Unix like)
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: Run script
run: bash scripts/choosenim-unix-init.sh -y

- name: Update path
run: echo "~/.nimble/bin" >> $GITHUB_PATH

- name: Test Nim works
run: nim --version
98 changes: 0 additions & 98 deletions analytics.md

This file was deleted.

1 change: 0 additions & 1 deletion bin/.gitkeep

This file was deleted.

12 changes: 4 additions & 8 deletions choosenim.nimble
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Package
import std/[os, strutils]

version = "0.8.4"
author = "Dominik Picheta"
Expand All @@ -15,13 +16,8 @@ skipExt = @["nim"]

# Note: https://github.com/dom96/choosenim/issues/233 (need to resolve when updating Nimble)
requires "nim >= 1.2.6", "nimble#8f7af86"
when defined(macosx):
requires "libcurl >= 1.0.0"
requires "analytics >= 0.3.0"
requires "osinfo >= 0.3.0"
requires "libcurl >= 1.0.0"
requires "https://github.com/ire4ever1190/osinfo#aa7d296"
requires "zippy >= 0.7.2"
when defined(windows):
requires "puppy 1.5.4"

task release, "Build a release binary":
exec "nimble build -d:release"
requires "puppy >= 1.5.4"
18 changes: 18 additions & 0 deletions config.nims
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const target {.strdefine: "zig.target".} = ""
if target != "":
switch("cc", "clang")
let zigCmd = "zigcc" & (if defined(windows): ".cmd" else: "")
switch("clang.exe", zigCmd)
switch("clang.linkerexe", zigCmd)
let targetArgs = "-target " & target
switch("passL", targetArgs)
switch("passC", targetArgs)

when defined(macosx):
# We need to define extra search paths
# Found via the default paths here
# https://discussions.apple.com/thread/2390561?sortBy=best#11330927022
switch("passL", "-F/Library/Frameworks -F/System/Library/Frameworks -F/System/Library/Frameworks/Security.framework -L/usr/lib -L/usr/local/lib")
switch("passL", "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk")

switch("d", "zippyNoSimd")
Loading

0 comments on commit b908f11

Please sign in to comment.