diff --git a/.github/ci.yml b/.github/ci.yml new file mode 100644 index 00000000..0bc9f003 --- /dev/null +++ b/.github/ci.yml @@ -0,0 +1,75 @@ +name: ci + +on: [push, pull_request] + +env: + project: 'release-node' + +jobs: + + test: + strategy: + matrix: + node-version: [12.x, 14.x] + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + + - name: Checkout + uses: actions/checkout@v2 + + # verify the version in package.json matches the release tag + - name: Version + uses: tcurdt/action-verify-version-npm@master + + - name: Setup Node ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Cache + id: cache-modules + uses: actions/cache@v2 + with: + path: node_modules + key: ${{ matrix.node-version }}-${{ runner.OS }}-build-${{ hashFiles('package.json') }} + + - name: Install + if: steps.cache-modules.outputs.cache-hit != 'true' + run: npm install + + - name: Test + run: npm test + + # create release artifacts to publish as github release + # - name: Upload + # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + # uses: actions/upload-artifact@v2 + # with: + # name: ${{ env.project }}_${{ matrix.os }}_${{ matrix.node-version }} + # path: | + # !.git + # !.github + # !node_modules + # . + + release: + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + needs: [test] + runs-on: ubuntu-latest + steps: + + # - name: Download + # uses: actions/download-artifact@v2 + # with: + # path: artifacts + # - name: Archives + # run: find artifacts -mindepth 1 -maxdepth 1 -exec tar -C {} -cvzf {}.tgz . \; + + - name: Release + uses: softprops/action-gh-release@v1 + # with: + # files: | + # artifacts/*.tgz + env: + GITHUB_TOKEN: ${{ secrets.PAT }} diff --git a/.github/cleanup.yml b/.github/cleanup.yml new file mode 100644 index 00000000..28568bd2 --- /dev/null +++ b/.github/cleanup.yml @@ -0,0 +1,17 @@ +name: cleanup + +on: + schedule: + - cron: '1 1 * * 1' # once a week clean out old artifacts + +jobs: + + expire: + runs-on: ubuntu-latest + steps: + + - name: Expire Artifacts + uses: kolpav/purge-artifacts-action@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + expire-in: 1hour diff --git a/.github/dockerhub.yml b/.github/dockerhub.yml new file mode 100644 index 00000000..5897c0d3 --- /dev/null +++ b/.github/dockerhub.yml @@ -0,0 +1,35 @@ +name: dockerhub + +on: + release: + types: [published] + +env: + project: 'release-node' + +jobs: + + dockerhub: + runs-on: ubuntu-latest + steps: + + - name: Checkout + uses: actions/checkout@v2 + + - name: Build + run: | + docker build -t ${{ env.project }} . + + - name: Login + env: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + run: echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin + + - name: Tag + run: | + docker tag ${{ env.project }} ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.project }}:${GITHUB_REF/refs\/tags\/v/} + docker tag ${{ env.project }} ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.project }}:latest + + - name: Push + run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.project }} diff --git a/.github/npm.yml b/.github/npm.yml new file mode 100644 index 00000000..5a6bafdd --- /dev/null +++ b/.github/npm.yml @@ -0,0 +1,21 @@ +name: npm + +on: + release: + types: [published] + +jobs: + + npm: + runs-on: ubuntu-latest + steps: + + - name: Checkout + uses: actions/checkout@v2 + + - name: Publish + env: + NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} + run: | + npm config set //registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN + npm publish --access=public