Skip to content

Commit

Permalink
ci: add release and validation pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
danijelTxFusion committed Jan 9, 2024
1 parent f57d5e0 commit aedd878
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 7 deletions.
File renamed without changes.
File renamed without changes.
35 changes: 35 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 "[email protected]" \
"@semantic-release/[email protected]" \
"@semantic-release/[email protected]" \
"@semantic-release/[email protected]" \
"@semantic-release/[email protected]"
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
12 changes: 5 additions & 7 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
name: Test Java SDK library

on:
workflow_dispatch:
pull_request:
branches:
- master
push:
branches:
- develop
branches: [master]
types: [ opened, reopened, synchronize ]

jobs:
test:
name: Test java project
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
71 changes: 71 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -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"
]
}

0 comments on commit aedd878

Please sign in to comment.