diff --git a/.github/semantic.yml b/.github/semantic.yml new file mode 100644 index 00000000..34b7f4d8 --- /dev/null +++ b/.github/semantic.yml @@ -0,0 +1,12 @@ +# Always validate the PR title AND all the commits +titleAndCommits: true +# Require at least one commit to be valid +# this is only relevant when using commitsOnly: true or titleAndCommits: true, +# which validate all commits by default +anyCommit: true +# Allow use of Merge commits (eg on github: "Merge branch 'master' into feature/ride-unicorns") +# this is only relevant when using commitsOnly: true (or titleAndCommits: true) +allowMergeCommits: false +# Allow use of Revert commits (eg on github: "Revert "feat: ride unicorns"") +# this is only relevant when using commitsOnly: true (or titleAndCommits: true) +allowRevertCommits: false diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..01ae6de2 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,66 @@ +name: Build + +on: [push, pull_request] + +jobs: + + frontend: + name: Front-end + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: '14.17.0' + - run: yarn install && CI=false yarn run build + working-directory: ./web + + backend: + name: Back-end + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: '^1.16.5' + - run: go version + - name: Build + run: | + go build -race -ldflags "-extldflags '-static'" + working-directory: ./ + + release-and-push: + name: Release And Push + runs-on: ubuntu-latest + if: github.repository == 'casbin/casnode' && github.event_name == 'push' + needs: [ frontend, backend ] + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: 12 + + - name: Release + run: yarn global add semantic-release@17.4.4 && semantic-release + env: + GH_TOKEN: ${{ secrets.GH_BOT_TOKEN }} + + + - name: Log in to Docker Hub + uses: docker/login-action@v1 + if: github.repository == 'casbin/casnode' && github.event_name == 'push' &&steps.should_push.outputs.push=='true' + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + + - name: Push to Docker Hub + uses: docker/build-push-action@v2 + if: github.repository == 'casbin/casnode' && github.event_name == 'push' && steps.should_push.outputs.push=='true' + with: + push: true + tags: casbin/casnode:${{steps.get-current-tag.outputs.tag }},casbin/casnode:latest diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 00000000..408d0989 --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,22 @@ +{ + "debug": true, + "branches": [ + "+([0-9])?(.{+([0-9]),x}).x", + { + "name": "rc" + }, + { + "name": "beta", + "prerelease": true + }, + { + "name": "alpha", + "prerelease": true + } + ], + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + "@semantic-release/github" + ] +}