diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..28011eec --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,91 @@ +name: Release + +on: + push: + tags: + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + +jobs: + test: + name: Test + runs-on: ubuntu-latest + timeout-minutes: 8 + steps: + - name: Checkout repository from GitHub + uses: actions/checkout@v3 + - name: Setup npm + uses: actions/setup-node@v3 + with: + node-version: '16' + - name: Install dependencies + run: npm install + - name: Run tests + run: npm run test + + deploy-example: + name: Deploy example to GitHub Pages + runs-on: ubuntu-latest + steps: + - name: Checkout repository from GitHub + uses: actions/checkout@v3 + - name: Setup npm + uses: actions/setup-node@v3 + with: + node-version: '16' + - name: Install dependencies + run: npm install + - name: Build example + run: npm run build:example + - name: Deploy to GitHub Pages + run: | + git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/ubilabs/react-geosuggest.git + npm run publish:example -- -u "github-actions-bot " + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + create-release: + name: Create Release + runs-on: ubuntu-latest + outputs: + upload_url: ${{ steps.create_release.outputs.upload_url }} + steps: + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + + publish-npm-package: + name: Publish to NPM + runs-on: ubuntu-latest + steps: + - name: Checkout repository from GitHub + uses: actions/checkout@v3 + - name: Setup npm + uses: actions/setup-node@v3 + with: + node-version: '16' + registry-url: 'https://registry.npmjs.org' + # npm cache folder is in ~/, not within the working directory + - name: Cache npm directory + uses: actions/cache@v3 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + - name: Install dependencies + run: npm install + - name: Build module + run: npm run build:module + - name: Run tests + run: npm run test + - name: Publish + run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_BOT_ACCESS_TOKEN }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 00000000..e24f7949 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,23 @@ +name: Run Tests + +on: + push: + branches-ignore: + - main + +jobs: + test: + name: Test + runs-on: ubuntu-latest + timeout-minutes: 8 + steps: + - name: Checkout repository from GitHub + uses: actions/checkout@v3 + - name: Setup npm + uses: actions/setup-node@v3 + with: + node-version: '16' + - name: Install dependencies + run: npm install + - name: Run tests + run: npm run test diff --git a/package.json b/package.json index 91f9abf9..0418e7f4 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,7 @@ "preversion": "npm test", "version": "npm run build:browser && npm run changelog && git add .", "postversion": "git push && git push --tags && npm run publish:example", - "publish:example": "npm run build:example && gh-pages -d example/dist" + "publish:example": "gh-pages -d example/dist" }, "readmeFilename": "README.md", "keywords": [