diff --git a/.github/workflows/manual_release.yml b/.github/workflows/manual_publish.yml similarity index 100% rename from .github/workflows/manual_release.yml rename to .github/workflows/manual_publish.yml diff --git a/.github/workflows/release.yaml b/.github/workflows/publish.yaml similarity index 100% rename from .github/workflows/release.yaml rename to .github/workflows/publish.yaml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8df760c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,35 @@ +name: Release +on: + workflow_dispatch: + +permissions: + contents: read # for checkout + +jobs: + release: + name: Release + runs-on: ubuntu-latest + permissions: + contents: write # to be able to publish a GitHub release + issues: write # to be able to comment on released issues + pull-requests: write # to be able to comment on released pull requests + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: "lts/*" + - name: Install dependencies + run: | + npm install -g "semantic-release@21.0.7" \ + "@semantic-release/commit-analyzer@11.1.0" \ + "@semantic-release/changelog@6.0.3" \ + "@semantic-release/git@10.0.1" \ + "@semantic-release/github@9.0.4" + - name: Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: npx semantic-release \ No newline at end of file diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index efe4204..9f87e49 100755 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,12 +1,10 @@ name: Test Java SDK library on: + workflow_dispatch: pull_request: - branches: - - master - push: - branches: - - develop + branches: [master] + types: [ opened, reopened, synchronize ] jobs: test: @@ -14,9 +12,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Set up JDK 8 + - name: Set up JDK uses: actions/setup-java@v1 with: - java-version: 1.8 + java-version: 11 - name: Test with Gradle run: gradle clean test diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml new file mode 100644 index 0000000..69b300d --- /dev/null +++ b/.github/workflows/validate.yml @@ -0,0 +1,71 @@ +name: Validate +on: + pull_request: + branches: [master] + types: [ opened, reopened, synchronize ] + +permissions: + contents: read # for checkout + +jobs: + lint: + name: Check code format + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Test with Gradle + run: gradle spotlessCheck + commits: + name: Check commits + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: "lts/*" + - name: Install dependencies + run: npm install -g @commitlint/cli @commitlint/config-conventional + - name: Configure + run: | + echo 'module.exports = {"extends": ["@commitlint/config-conventional"]}' > commitlint.config.js + - name: Validate + run: | + git fetch + npx commitlint \ + --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} \ + --to ${{ github.event.pull_request.head.sha }} \ + --verbose + commits-fork: + name: Check commits from forks + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: "lts/*" + - name: Install dependencies + run: npm install -g @commitlint/cli @commitlint/config-conventional + - name: Configure + run: | + echo 'module.exports = {"extends": ["@commitlint/config-conventional"]}' > commitlint.config.js + - name: Validate + run: | + git fetch origin "+refs/pull/${{ github.event.pull_request.number }}/head:refs/pull/${{ github.event.pull_request.number }}/head" + git checkout "refs/pull/${{ github.event.pull_request.number }}/head" + npx commitlint \ + --from HEAD~${{ github.event.pull_request.commits }} \ + --to HEAD \ + --verbose \ No newline at end of file diff --git a/.releaserc b/.releaserc new file mode 100644 index 0000000..3a36f58 --- /dev/null +++ b/.releaserc @@ -0,0 +1,25 @@ +{ + "repositoryUrl": "https://github.com/zksync-sdk/zksync2-java.git", + "branches": "main", + "debug": true, + "addReleases": "top", + "preset": "angular", + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + [ + "@semantic-release/changelog", + { + "changelogFile": "CHANGELOG.md" + } + ], + [ + "@semantic-release/git", + { + "assets": ["CHANGELOG.md"], + "message": "${nextRelease.version} version bump [skip ci]\n\n${nextRelease.notes}" + } + ], + "@semantic-release/github" + ] +} \ No newline at end of file