From de913161356fd6d5f3461d51e1e7af9f81c894c3 Mon Sep 17 00:00:00 2001 From: Phillip Oldham Date: Mon, 28 Dec 2020 14:26:59 +0100 Subject: [PATCH] Configure automated releases with build artifacts --- .github/workflows/ci.yml | 4 +- .github/workflows/release.yml | 95 ++++++++++++++++++++++++++++++++++- Makefile | 11 +++- README.md | 36 ++++++------- src/ll.nim | 14 +++--- version | 1 + 6 files changed, 132 insertions(+), 29 deletions(-) create mode 100644 version diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9902024..165764b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,10 +27,10 @@ jobs: include: - target: os: linux - builder: ubuntu-18.04 + builder: ubuntu-latest - target: os: macos - builder: macos-10.15 + builder: macos-latest name: '${{ matrix.target.os }}-nim${{ matrix.target.nim_version }} (${{ matrix.branch }})' runs-on: ${{ matrix.builder }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3fd045f..1eb50f0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,9 +8,13 @@ on: - main - master +env: + RELEASE_VERSION: production + UPLOAD_URL: "" + jobs: release: - name: Create Release + name: "Release" runs-on: ubuntu-latest steps: @@ -29,7 +33,8 @@ jobs: uses: gittools/actions/gitversion/execute@v0.9.6 - name: "[Version] Capture" - run: echo "RELEASE_VERSION=${{ steps.gitversion.outputs.semVer }}" >> $GITHUB_ENV + run: | + echo "RELEASE_VERSION=${{ steps.gitversion.outputs.semVer }}" >> $GITHUB_ENV - name: "[Release] Create" id: create_release @@ -43,3 +48,89 @@ jobs: Please see the changelog for details of this release draft: false prerelease: false + + - name: "[Release] Capture" + run: | + echo "UPLOAD_URL=${{ steps.create_release.outputs.upload_url }}" >> $GITHUB_ENV + + - name: "[Release] Capture vars" + run: | + echo "${{env.RELEASE_VERSION}}" > version + echo "${{env.UPLOAD_URL}}" > uploadurl + + - name: "[Release] Upload artifacts" + uses: actions/upload-artifact@v1 + with: + name: details + path: version + + - name: "[Release] Upload artifacts" + uses: actions/upload-artifact@v1 + with: + name: details + path: uploadurl + + artifacts: + strategy: + fail-fast: false + max-parallel: 20 + matrix: + os: + - ubuntu-latest + - macos-latest + + name: "Build: ${{ matrix.os }}" + runs-on: ${{ matrix.os }} + needs: release + + steps: + - name: "[Git] Checkout code" + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: "[Release] Download artifacts" + uses: actions/download-artifact@v1 + with: + name: details + + - name: "[Env] Write" + run: | + mv details/* . + echo "RELEASE_VERSION=$(cat version)" >> $GITHUB_ENV + echo "UPLOAD_URL=$(cat uploadurl)" >> $GITHUB_ENV + + - name: "[Build] Install deps" + if: runner.os == 'Linux' + run: | + sudo apt-fast update -qq + sudo apt-fast --no-install-recommends -yq install curl git + + - name: "[Build] Install asdf" + run: | + [ -d ~/.asdf ] || git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.8.0 + + - name: "[Build] Install nim" + run: | + source $HOME/.asdf/asdf.sh + [ -e $(asdf plugin list|grep nim) ] && asdf plugin add nim + asdf install nim latest + + - name: "[Build] Create build for ${{ matrix.os }}" + run: | + source $HOME/.asdf/asdf.sh + asdf info + asdf global nim $(asdf list nim|tail -n 1) + make release + tar czf ll-${{env.RELEASE_VERSION}}-${{ matrix.os }}.tar.gz ./ll + + - name: "[Release] Upload build for ${{ matrix.os }} to ${{env.UPLOAD_URL}}" + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{env.UPLOAD_URL}} + asset_path: ll-${{env.RELEASE_VERSION}}-${{ matrix.os }}.tar.gz + asset_name: ll-${{env.RELEASE_VERSION}}-${{ matrix.os }}.tar.gz + asset_content_type: application/gzip diff --git a/Makefile b/Makefile index fdccfe3..b96b5e3 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,16 @@ profile: ## run profiler @nimble profile release: ## release build, optimised for speed - @nimble -y build --nilseqs:on --verbose --opt:speed -d:release # --passC:-Ofast --threads:off --threadanalysis:off + @nimble -y build \ + -d:release \ + --gc:arc \ + --deepCopy:on \ + --nilseqs:on \ + --verbose \ + --opt:speed \ + # --passC:-Ofast \ + # --threads:off \ + # --threadanalysis:off install: release ## create a release build and install to /usr/local/bin @mv ./ll /usr/local/bin/ll diff --git a/README.md b/README.md index 6902479..d1ac65b 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,22 @@ -# `ll` - a more informative `ls`, based on [`k`][1] +# `ll` - a more informative `ls`, based on [`k`][k] ![CI](https://github.com/OldhamMade/ll/workflows/CI/badge.svg) ## Description -`ll` is an alternative to [`k`][1], which was created to make +`ll` is an alternative to [`k`][k], which was created to make directory listings more informative and readable, using colour to add visual weight to important information in the listing. ### Motivation -[`k`][1] only works with [`zsh`][2], and I've found that it can +[`k`][k] only works with [`zsh`][zsh], and I've found that it can occasionally be a little slow when working with large directories or with large git repositories. I was looking for a project which would -be a good match to learn/use [`nim`][3], and this seemed like a great +be a good match to learn/use [`nim`][nim], and this seemed like a great opportunity to make something a little more general-purpose that could -be used without the [`zsh`][2] dependency. +be used without the [`zsh`][zsh] dependency. ## Features @@ -69,17 +69,19 @@ listings with many git-tracked entries `ll` is still sub-second. ## Installation -Binary distributions are planned, but for now it's possible to build -and install using the following instructions. +[The latest binary distribution is avilable here.][builds] + +It is also possible to build and install using the following +instructions: ### Requirements -- [Nim][3], minimum v1.2.* +- [Nim][nim], minimum v1.2.* - `make` ### Steps -Firstly install [Nim][3]. I personally use [`asdf`][6] to manage Nim +Firstly install [Nim][nim]. I personally use [`asdf`][asdf] to manage Nim versions on my machine. With `asdf` installed, this is as simple as calling `asdf install nim latest`. @@ -110,9 +112,9 @@ That's it. For more options, pass `-?` or `--help`. - [ ] Support light themes - [ ] Support globs -### Fixes over [`k`][1] +### Fixes over [`k`][k] -* [`k`][1] has an odd behaviour; given `pwd` is a git-tracked +* [`k`][k] has an odd behaviour; given `pwd` is a git-tracked directory, if you `k somedir` where `somedir` contains git-tracked directories but isn't itself tracked, `k` reports as though it is working inside a work-tree. `ll` reports this as one would expect, as @@ -121,7 +123,7 @@ though `pwd` is `somedir`. **UPDATE:** This has now ### Future plans -According to the [`k`][1] source, there are future plans to colorise +According to the [`k`][k] source, there are future plans to colorise file permissions. If this happens, I plan to bring those changes over. If any other enhancements are added, I hope to port those also. @@ -164,8 +166,8 @@ You may view the LICENSE in which this software is provided to you > SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -[1]: https://github.com/supercrabtree/k -[2]: https://en.wikipedia.org/wiki/Z_shell -[3]: https://nim-lang.org -[4]: https://en.wikipedia.org/wiki/Kanban -[6]: https://github.com/asdf-vm/asdf +[k]: https://github.com/supercrabtree/k +[zsh]: https://en.wikipedia.org/wiki/Z_shell +[nim]: https://nim-lang.org +[asdf]: https://github.com/asdf-vm/asdf +[builds]: https://github.com/OldhamMade/ll/releases/latest diff --git a/src/ll.nim b/src/ll.nim index 15d3503..69ce534 100644 --- a/src/ll.nim +++ b/src/ll.nim @@ -20,8 +20,8 @@ import llpkg/display const AppName = "ll" - AppVersion = "0.1.1" - AppVersionFull = "$1, version $2".format(AppName, AppVersion) + AppVersion = staticRead("../version") + AppVersionFull = "$1, version: $2".format(AppName, AppVersion) type @@ -81,19 +81,19 @@ type id: tuple[device: DeviceId, file: FileId] kind: FileType size: BiggestInt - permissions: set[FilePermission] + owner: tuple[group: Gid, user: Uid] + symlink: string + symlinkBroken: bool linkCount: BiggestInt + creationTime: times.Time lastAccessTime: times.Time lastWriteTime: times.Time lastWriteTimeNanosec: int - creationTime: times.Time blocks: int - owner: tuple[group: Gid, user: Uid] - symlink: string - symlinkBroken: bool executable: bool mode: Mode hidden: bool + permissions: set[FilePermission] gitInsideWorkTree: bool gitStatus: GitStatus diff --git a/version b/version new file mode 100644 index 0000000..23e3185 --- /dev/null +++ b/version @@ -0,0 +1 @@ +development