Last active
May 22, 2021 23:53
-
-
Save juancarlospaco/414c1253e930720978cccb5a5ff1c5bc to your computer and use it in GitHub Desktop.
.github/workflows/build.yml GitHub Action for Nim (Generic Base Template)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Nim ๐ | |
on: [push] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
- uses: actions/setup-python@v1 | |
- uses: actions/setup-node@v1 | |
- name: Set Global Environment Variables | |
uses: allenevans/[email protected] | |
with: | |
CHOOSENIM_CHOOSE_VERSION: "1.0.4" | |
CHOOSENIM_NO_ANALYTICS: 1 | |
- name: Update Python PIP | |
run: pip install --upgrade --disable-pip-version-check pip | |
- name: Update NodeJS NPM | |
run: npm install npm | |
- name: Cache choosenim | |
id: cache-choosenim | |
uses: actions/cache@v1 | |
with: | |
path: ~/.choosenim | |
key: ${{ runner.os }}-choosenim-$CHOOSENIM_CHOOSE_VERSION | |
- name: Cache nimble | |
id: cache-nimble | |
uses: actions/cache@v1 | |
with: | |
path: ~/.nimble | |
key: ${{ runner.os }}-nimble-$CHOOSENIM_CHOOSE_VERSION | |
- name: Install Nim via Choosenim | |
if: steps.cache-choosenim.outputs.cache-hit != 'true' || steps.cache-nimble.outputs.cache-hit != 'true' | |
run: | | |
curl https://nim-lang.org/choosenim/init.sh -sSf > init.sh | |
sh init.sh -y | |
- name: Nimble Refresh | |
run: | | |
export PATH=$HOME/.nimble/bin:$PATH | |
nimble -y refresh | |
- name: Nimble Install dependencies | |
run: | | |
export PATH=$HOME/.nimble/bin:$PATH | |
nimble -y install --depsOnly | |
- name: Nimble Check package validity | |
run: | | |
export PATH=$HOME/.nimble/bin:$PATH | |
nimble check | |
- name: Compile DEBUG Mode | |
run: | | |
export PATH=$HOME/.nimble/bin:$PATH | |
nimble build | |
- name: Compile RELEASE Mode | |
run: | | |
export PATH=$HOME/.nimble/bin:$PATH | |
nimble build -d:release -d:danger | |
- name: Nimble install | |
run: | | |
export PATH=$HOME/.nimble/bin:$PATH | |
nimble install | |
- name: Unittest project | |
run: | | |
export PATH=$HOME/.nimble/bin:$PATH | |
nimble test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Upload to PYPI ๐ | |
on: | |
release: | |
types: [created] | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
- uses: actions/setup-python@v1 | |
- name: Set Global Environment Variables | |
uses: allenevans/[email protected] | |
with: | |
CHOOSENIM_CHOOSE_VERSION: "1.0.4" | |
CHOOSENIM_NO_ANALYTICS: 1 | |
TWINE_NON_INTERACTIVE: 1 | |
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} # https://github.com/USER/REPO/settings/secrets/new | |
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
MAIN_MODULE: "src/faster_than_requests.nim" | |
#TWINE_REPOSITORY_URL: "https://test.pypi.org/legacy/" # Upload to PYPI Testing fake server. | |
#TWINE_REPOSITORY: "https://test.pypi.org/legacy/" | |
- name: Update Python PIP | |
run: pip3 install --upgrade --disable-pip-version-check pip setuptools twine | |
- name: Cache choosenim | |
id: cache-choosenim | |
uses: actions/cache@v1 | |
with: | |
path: ~/.choosenim | |
key: ${{ runner.os }}-choosenim-$CHOOSENIM_CHOOSE_VERSION | |
- name: Cache nimble | |
id: cache-nimble | |
uses: actions/cache@v1 | |
with: | |
path: ~/.nimble | |
key: ${{ runner.os }}-nimble-$CHOOSENIM_CHOOSE_VERSION | |
- name: Install Nim via Choosenim | |
if: steps.cache-choosenim.outputs.cache-hit != 'true' || steps.cache-nimble.outputs.cache-hit != 'true' | |
run: | | |
curl https://nim-lang.org/choosenim/init.sh -sSf > init.sh | |
sh init.sh -y | |
- name: Nimble Refresh | |
run: | | |
export PATH=$HOME/.nimble/bin:$PATH | |
nimble -y refresh | |
- name: Nimble Install dependencies | |
run: | | |
export PATH=$HOME/.nimble/bin:$PATH | |
nimble -y install nimpy | |
- name: Prepare Files | |
run: | | |
mkdir --verbose --parents dist/ | |
rm --verbose --force --recursive *.c *.h *.so *.pyd *.egg-info/ dist/*.zip | |
cp --verbose --force ~/.choosenim/toolchains/nim-$CHOOSENIM_CHOOSE_VERSION/lib/nimbase.h nimbase.h | |
- name: Compile to C | |
run: | | |
export PATH=$HOME/.nimble/bin:$PATH | |
nim compileToC --compileOnly -d:release -d:danger -d:ssl --threads:on --app:lib --opt:speed --gc:markAndSweep --nimcache:. $MAIN_MODULE | |
- name: Publish to PYPI | |
run: | | |
python3 setup.py --verbose sdist --formats=zip | |
rm --verbose --force --recursive *.c *.h *.so *.pyd *.egg-info/ | |
twine upload --verbose --disable-progress-bar dist/*.zip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment