From f468d03d41cbd8f7df4c319fd2460dcd57af9513 Mon Sep 17 00:00:00 2001 From: Joshua Garde Date: Tue, 25 Jul 2023 18:43:15 -0700 Subject: [PATCH] Initial gh actions workflow --- .github/workflows/build.yml | 77 +++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..97f17c8 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,77 @@ +name: Build 'n Deploy +permissions: + packages: write + +on: + push: + branches: + - '*' + tags-ignore: + - '*' + paths-ignore: + - 'package.json' + - 'package-lock.json' + - 'bumpver.toml' + +jobs: + build: + name: build, lint, and test + runs-on: ubuntu-latest + steps: + # -- Setup -- + - uses: getsentry/action-github-app-token@v2 + name: my-app-install token + id: podaac-cicd + with: + app_id: ${{ secrets.CICD_APP_ID }} + private_key: ${{ secrets.CICD_APP_PRIVATE_KEY }} + - uses: actions/checkout@v3 + with: + repository: ${{ github.repository }} + token: ${{ steps.podaac-cicd.outputs.token }} + - uses: actions/setup-python@v4 + with: + python-version: '3.9' + - name: Install bumpver + run: pip3 install bumpver + - uses: actions/setup-node@v3 + with: + node-version: 18 + registry-url: 'https://npm.pkg.github.com' + - name: Setup git user + run: | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config user.name "github-actions[bot]" + - name: Install package + run: npm ci + + # -- Linting -- + - name: Lint + run: npm run lint + + # -- Version Bumping -- + - name: Bump alpha version + if: github.ref == 'refs/heads/develop' + run: | + TAG=$(bumpver show -e | awk -F= '$1 == "TAG" {print $2};') + if [ $TAG == 'final' ]; then + # Bump patch version first then append tag + bumpver update --patch --tag alpha --tag-num + else + bumpver update --tag alpha --tag-num + fi + - name: Bump rc version + if: startsWith(github.ref, 'refs/heads/release/') + run: bumpver update --patch --tag rc --tag-num + - name: Release version + if: github.ref == 'refs/heads/main' + run: bumpver update --patch --tag final + + # -- Publish -- + - name: Publish + if: | + startsWith(github.ref, 'refs/heads/release/') || + github.ref == 'refs/heads/main' + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}