Feedback. #668
Workflow file for this run
This file contains 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: CI | |
on: | |
push: | |
release: | |
types: [published] | |
workflow_dispatch: | |
inputs: | |
deploy: | |
description: 'Deploy the website' | |
required: false | |
default: false | |
type: boolean | |
env: | |
TOIT_VERSION: v2.0.0-alpha.148 | |
BUILD_DIR: public | |
HAS_PROTOBUF: false | |
RUN_TESTS: true | |
ARTIFACT_EXTENSION: tgz | |
jobs: | |
snippets: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Setup Toit | |
id: setup-toit | |
uses: toitlang/action-setup@v1 | |
with: | |
toit-version: ${{ env.TOIT_VERSION }} | |
- name: Check snippets | |
shell: bash | |
run: | | |
export TOIT_SDK=${{ steps.setup-toit.outputs.toit-install-dir }}/toit | |
cd tools | |
$TOIT_SDK/bin/toit.pkg install | |
./run_all.sh | |
ci: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Install | |
env: | |
GITHUB_NPM_TOKEN: ${{ secrets.LEON_GITHUB_NPM_PAT }} | |
run: | | |
npm config set //npm.pkg.github.com/:_authToken=$GITHUB_NPM_TOKEN | |
yarn install | |
- name: Protobuf | |
if: env.HAS_PROTOBUF == 'true' | |
run: | | |
sudo apt-get update | |
sudo apt-get install protobuf-compiler | |
make protobuf | |
- name: Lint | |
run: | | |
yarn lint | |
- name: Test | |
if: env.RUN_TESTS == 'true' | |
run: | | |
yarn test:ci | |
- name: Build | |
run: | | |
yarn build | |
- name: Generate version | |
id: version | |
shell: bash | |
run: | | |
GIT_VERSION=$(tools/gitversion) | |
echo $GIT_VERSION | |
# Replace any '/' with '-'. | |
VERSION=${GIT_VERSION//\//-} | |
echo $VERSION | |
echo $VERSION > VERSION | |
echo VERSION=$VERSION >> $GITHUB_ENV | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
- name: Prepare artifacts | |
run: | | |
tar c -zf $VERSION.$ARTIFACT_EXTENSION -C $BUILD_DIR/ . | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build | |
retention-days: 2 | |
if-no-files-found: error | |
path: | | |
${{ env.VERSION }}.${{ env.ARTIFACT_EXTENSION }} | |
VERSION | |
deploy: | |
if: | | |
github.event.inputs.deploy == 'true' || | |
github.event_name == 'release' && !github.event.release.prerelease | |
# Only deploy if all tests passed. | |
needs: [ci] | |
runs-on: ubuntu-latest | |
steps: | |
# No need to checkout the project, since all we need is to download the | |
# build artifact from the build step. | |
- uses: actions/download-artifact@v4 | |
with: | |
name: build | |
path: build | |
- name: Untar | |
run: | | |
cd build | |
VERSION=$(cat VERSION) | |
tar x -zf $VERSION.$ARTIFACT_EXTENSION | |
rm $VERSION.$ARTIFACT_EXTENSION | |
- name: Disable Jekyll | |
run: | | |
touch build/.nojekyll | |
# This seems to be the simplest way to publish to a separate branch. | |
- name: Deploy | |
uses: peaceiris/actions-gh-pages@v4 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_branch: gh-pages | |
publish_dir: ./build | |
# Optional. This will create a CNAME file so GitHub Pages serves it | |
# under this domain. | |
cname: docs.toit.io |