diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..fd47158 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,50 @@ +name: Publish +on: + release: + types: + - published +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: master + token: ${{ secrets.ADMIN_GITHUB_TOKEN }} + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + - uses: actions/cache@v3 + id: yarn-cache + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' + registry-url: 'https://registry.npmjs.org' + - name: Get the version + id: vars + run: echo ::set-output name=tag::$(echo ${GITHUB_REF#"refs/tags/"}) + - name: Bump version + run: npm version ${{ steps.vars.outputs.tag }} --no-git-tag-version + - name: Commit files + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git commit -m "Bump to ${{ steps.vars.outputs.tag }}" -a + git tag -f ${{ steps.vars.outputs.tag }} + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.ADMIN_GITHUB_TOKEN }} + branch: master + force: true + tags: true + - name: Publish + run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}