Skip to content

Commit

Permalink
New version in vlang progremming language
Browse files Browse the repository at this point in the history
  • Loading branch information
tpanj committed Apr 1, 2024
1 parent c466932 commit 1740475
Show file tree
Hide file tree
Showing 14 changed files with 379 additions and 2,210 deletions.
160 changes: 160 additions & 0 deletions .github/workflows/binary_artifact.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
name: Build binary artifacts

on:
push:
tags:
- '*'

jobs:

build-linux:
runs-on: ubuntu-20.04
env:
ZIPNAME: cht_linux.zip
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
.github/workflows/retry.sh sudo apt-get update
.github/workflows/retry.sh sudo apt-get install --quiet -y build-essential libcurl4 libcurl4-openssl-dev
- name: Download V
run: |
tag="latest"
.github/workflows/retry.sh wget https://github.com/vlang/v/releases/$tag/download/v_linux.zip
unzip v_linux.zip
cd v
./v -version
- name: Compile
run: |
cd v
./v ../src -o ../cht
- name: Create ZIP archive
run: |
mkdir bin
mv cht bin
zip -r $ZIPNAME bin
- name: Create artifact
uses: actions/upload-artifact@v4
with:
name: linux
path: ${{ env.ZIPNAME }}

build-windows:
runs-on: windows-latest
env:
ZIPNAME: cht_windows.zip
timeout-minutes: 5
steps:
- uses: msys2/setup-msys2@v2
- uses: actions/checkout@v4
- name: Download V
run: |
Set-Variable -Name "tag" -Value latest
& curl -L https://github.com/vlang/v/releases/$tag/download/v_windows.zip -o v_windows.zip
& unzip .\v_windows.zip
& cd v
& .\v.exe -version
- name: Compile
run: |
cd v
.\v.exe ..\src -o ..\cht.exe
- name: Create archive
shell: msys2 {0}
run: |
mkdir bin
mv cht.exe bin
powershell Compress-Archive bin $ZIPNAME
- name: Create artifact
uses: actions/upload-artifact@v4
with:
name: windows
path: ${{ env.ZIPNAME }}

build-macos-x86_64:
runs-on: macos-latest
env:
ZIPNAME: cht_macos_x86_64.zip
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- name: Download V
run: |
tag=latest
wget https://github.com/vlang/v/releases/$tag/download/v_macos_x86_64.zip
unzip v_macos_x86_64.zip
cd v
./v -version
- name: Compile
run: |
cd v
./v ../src -o ../cht
- name: Create ZIP archive
run: |
mkdir bin
mv cht bin
zip -r $ZIPNAME bin
- name: Create artifact
uses: actions/upload-artifact@v4
with:
name: macos_x86_64
path: ${{ env.ZIPNAME }}

release:
name: Create Github Release
needs: [build-linux, build-windows, build-macos-x86_64] #, build-macos-arm64]
runs-on: ubuntu-latest
steps:
- name: Get short tag name
uses: jungwinter/split@v2
id: split
with:
msg: ${{ github.ref }}
separator: /
- name: Create Release
id: create_release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.split.outputs._2 }}
name: ${{ steps.split.outputs._2 }}
commit: ${{ github.sha }}
# draft: false
# prerelease: false

publish:
needs: [release]
runs-on: ubuntu-latest
strategy:
matrix:
version: [linux, windows, macos_x86_64] #, macos_arm64]
steps:
- uses: actions/checkout@v4
- name: Fetch artifacts
uses: actions/download-artifact@v4
with:
name: ${{ matrix.version }}
path: ./${{ matrix.version }}
- name: Get short tag name
uses: jungwinter/split@v2
id: split
with:
msg: ${{ github.ref }}
separator: /
- name: Get release
id: get_release_info
uses: leahlundqvist/get-release@v1.3.1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag_name: ${{ steps.split.outputs._2 }}
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1.0.2
# uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: ${{ matrix.version }}/cht_${{ matrix.version }}.zip
asset_name: cht_${{ matrix.version }}.zip
asset_content_type: application/zip
46 changes: 46 additions & 0 deletions .github/workflows/blank.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "master" branch
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-22.04 #ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

- name: Install dependencies
run: |
.github/workflows/retry.sh sudo apt-get update
.github/workflows/retry.sh sudo apt-get install --quiet -y build-essential libcurl4 libcurl4-openssl-dev
- name: Download V
run: |
tag="latest"
.github/workflows/retry.sh wget https://github.com/vlang/v/releases/$tag/download/v_linux.zip
unzip v_linux.zip
cd v
./v -version
- name: Compile
run: |
cd v
./v ../src -o ../cht
- name: Test cht
run: ./cht --version

4 changes: 4 additions & 0 deletions .github/workflows/retry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

while ! $@; do "command failed, retrying ..."; sleep 1; done

34 changes: 12 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,33 +58,20 @@ cht file:///tmp/saved_file -T
![Removing colors](doc/ss_lin1.png)

# Compiling
## Windows
Due to document length it is located separately [here](doc/compile_ms.md)

Use [vlang](https://vlang.io)

## Windows
```
v src -o cht.exe
```
## Linux
### Simplest & quickest
```sh
sudo apt install build-essential libcurl4-openssl-dev
gcc -Wall cht.c simple_config.c -lcurl -o cht
v src -o cht
sudo cp ./cht /usr/local/bin/ # "install" it
```
### Static & full under control
```sh
sudo apt install build-essential libcurl4-openssl-dev cmake
```
* download curl from https://curl.haxx.se/download.html,
* unpack it to src folder and rename folder to curl (do not leave it like curl-x.y.z)
```sh
cd curl
cmake -DCURL_STATICLIB=ON .
make libcurl # we need only this mudule
cd ..
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ../src
make
sudo make install # install it to /usr/local/bin
```
## External sources
* https://github.com/tapio/rlutil for cross platform console coloring
* https://github.com/Malvineous/cfgpath for managing config files
Expand All @@ -93,8 +80,11 @@ sudo make install # install it to /usr/local/bin
------------------

# TODO:
- [X] windows compile instructions
- [ ] Config file

# Deprecated:
- [X] windows compile instructions [here](doc/compile_ms.md)
- [X] complete cmake
- [X] ~~compile with openssl~~ → postponed since this is not needed for now
- [ ] complete functionallity all features of the cht.sh command line
- [ ] sorry Mac users, only tasted on Linux and winXP-10
- [X] sorry Mac users, only tasted on Linux and winXP-10
66 changes: 0 additions & 66 deletions src/CMakeLists.txt

This file was deleted.

Loading

0 comments on commit 1740475

Please sign in to comment.