diff --git a/.github/workflows/egg-jest.yml b/.github/workflows/egg-jest.yml new file mode 100644 index 0000000..63ae065 --- /dev/null +++ b/.github/workflows/egg-jest.yml @@ -0,0 +1,80 @@ +name: egg-jest +permissions: + contents: read + +on: + - pull_request + - push + +env: + NODE_LATEST_VERSION: '24' + +jobs: + jest: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + node-version: ['20', '22', '24'] + + steps: + - uses: actions/checkout@v6 + + - uses: actions/setup-node@v6 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + + - name: dependencies + working-directory: egg + run: npm ci + + - name: jest + working-directory: egg + run: npm run all + + npm: + runs-on: ubuntu-latest + needs: jest + + if: "github.event_name == 'push' && startsWith(github.ref, 'refs/tags')" + + environment: + name: npm-egg + url: https://www.npmjs.com/package/atsds-egg + permissions: + id-token: write + + steps: + - uses: actions/checkout@v6 + + - name: recovery tag information + run: git fetch --tags --force + + - uses: actions/setup-node@v6 + with: + node-version: ${{ env.NODE_LATEST_VERSION }} + cache: 'npm' + + - name: version + working-directory: egg + run: npm version from-git --no-git-tag-version + + - name: extract tag + run: | + GIT_TAG=${GITHUB_REF#refs/tags/} + TAG=$(echo $GIT_TAG | sed -E 's/^v//' | sed -E 's/[0-9\.-]//g' | sed -E 's/^$/latest/g') + echo TAG=$TAG >> $GITHUB_ENV + + - name: dependencies + working-directory: egg + run: npm ci + + - name: build + working-directory: egg + run: npm run build + + - name: publish + working-directory: egg + run: npm publish --tag $TAG