Improved workflows
h3rald h3rald@h3rald.com
Mon, 31 Jul 2023 13:27:40 +0200
3 files changed,
107 insertions(+),
6 deletions(-)
M
.github/workflows/add-artifacts-to-current-release.yml
→
.github/workflows/add-artifacts-to-current-release.yml
@@ -55,9 +55,9 @@ - name: Install Nim and deps
run: | curl https://nim-lang.org/choosenim/init.sh -sSf > init.sh sh init.sh -y - nimble install -y zippy nimble install -y nifty nifty install + # Build for Linux - name: Build (Linux) run: nimble build -d:release --gcc.exe:musl-gcc --gcc.linkerexe:musl-gcc -d:ssl -d:useOpenSsl3 --opt:size
M
.github/workflows/ci.yml
→
.github/workflows/ci.yml
@@ -18,7 +18,7 @@ jobs:
# This workflow contains a single job called "ci" ci: # The type of runner that the job will run on - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest env: CHOOSENIM_CHOOSE_VERSION: stable CHOOSENIM_NO_ANALYTICS: 1@@ -42,14 +42,18 @@
- name: Install nifty run: nimble install -y nifty - - name: Install zippy - run: nimble install zippy - - name: Install deps run: nifty install - name: Build run: nimble build -d:release -d:ssl -d:useOpenSsl3 --opt:size --gcc.exe:musl-gcc --gcc.linkerexe:musl-gcc --cpu:amd64 --os:linux - + + - name: UPX + uses: svenstaro/upx-action@v2 + with: + files: | + min + args: --best --force + - name: Test run: ./min tests/all.min
A
.github/workflows/test.yml
@@ -0,0 +1,97 @@
+name: Add artifacts to current release + +# Controls when the action will run. +on: + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + release: + name: "Run all tests" + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - ubuntu-latest + - macos-latest + - windows-latest + + env: + CHOOSENIM_CHOOSE_VERSION: stable + CHOOSENIM_NO_ANALYTICS: 1 + + steps: + # Cancel other actions of the same type that might be already running + - name: "Cancel similar actions in progress" + uses: styfle/cancel-workflow-action@0.6.0 + with: + access_token: ${{ github.token }} + + # Detects OS and provide Nim-friendly OS identifiers + - name: Detect current OS + id: os + run: echo "::set-output name=id::${{matrix.os == 'ubuntu-latest' && 'linux' || matrix.os == 'macos-latest' && 'macosx' || matrix.os == 'windows-latest' && 'windows'}}" + + # Checks out the repository + - uses: actions/checkout@v2 + + # Installs libraries + - name: install musl-gcc + run: sudo apt-get install -y musl-tools + if: matrix.os == 'ubuntu-latest' + + # Sets path (Linux, macOS) + - name: Update $PATH + run: echo "$HOME/.nimble/bin" >> $GITHUB_PATH + if: matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest' + + # Sets path (Windows) + - name: Update %PATH% + run: echo "${HOME}/.nimble/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + if: matrix.os == 'windows-latest' + + # Install the Nim compiler and dependencies + - name: Install Nim and deps + run: | + curl https://nim-lang.org/choosenim/init.sh -sSf > init.sh + sh init.sh -y + nimble install -y nifty + nifty install + + # Build for Linux + - name: Build (Linux) + run: nimble build -d:release --gcc.exe:musl-gcc --gcc.linkerexe:musl-gcc -d:ssl -d:useOpenSsl3 --opt:size + if: matrix.os == 'ubuntu-latest' + + # Build for macOS/Windows + - name: Build (macOS, Windows) + run: nimble build -d:release -d:ssl -d:useOpenSsl3 --opt:size + if: matrix.os == 'macos-latest' || matrix.os == 'windows-latest' + + # UPX compress (*nix) + - name: UPX + uses: svenstaro/upx-action@v2 + with: + files: | + min + args: --best --force + if: matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest' + + # UPX compress (Windows) + - name: UPX + uses: svenstaro/upx-action@v2 + with: + files: | + min.exe + args: --best --force + if: matrix.os == 'windows-latest' + + # Test (*nix) + - name: Test + run: ./min tests/all.min + if: matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest' + + # Test (*Windows) + - name: Test + run: min tests/all.min + if: matrix.os == 'windows-latest'