Update the CI. (#73) #123
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] | |
env: | |
BUILD_DIR: build | |
HAS_PROTOBUF: false | |
RUN_TESTS: false | |
ARTIFACT_EXTENSION: tgz | |
jobs: | |
ci: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
# We are using deprecated functionality. Downgrade Node so we still compile. | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 16 | |
- 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 | |
- name: Upload release artifacts | |
if: | | |
github.event_name == 'release' || | |
github.event_name == 'push' && github.ref_name == 'master' || | |
github.event_name == 'push' && startsWith(github.ref_name, 'release-v') | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: ${{ env.VERSION }}.${{ env.ARTIFACT_EXTENSION }} | |
asset_name: build.${{ env.ARTIFACT_EXTENSION }} | |
tag: ${{ github.event.release.tag_name }} | |
overwrite: true |