From 443e02ad9a55191b426e786cdeb9169e60768258 Mon Sep 17 00:00:00 2001 From: Zhigang Wang Date: Sun, 17 May 2026 13:16:31 +0200 Subject: [PATCH] Add CI and release GitHub workflows --- .github/workflows/ci.yml | 17 ++++++++++++++ .github/workflows/release.yml | 43 +++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..769a1eb --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,17 @@ +name: CI +on: + push: + pull_request: + schedule: + - cron: '0 6 * * 1' +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 8 + cache: maven + - run: mvn verify diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..374c2fa --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,43 @@ +name: Release +on: + workflow_dispatch: +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 8 + cache: maven + - name: Get version from pom.xml + run: | + VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) + echo "VERSION=v$VERSION" >> $GITHUB_ENV + - name: Check tag does not exist + run: | + git fetch --tags + if git rev-parse "$VERSION" >/dev/null 2>&1; then + echo "Tag $VERSION already exists"; exit 1; + fi + - name: Check release does not exist + run: | + if gh release view "$VERSION" >/dev/null 2>&1; then + echo "Release $VERSION already exists"; exit 1; + fi + env: + GH_TOKEN: ${{ github.token }} + - run: mvn package + - name: Create tag and release + run: | + git tag "$VERSION" + git push origin "$VERSION" + gh release create "$VERSION" \ + --title "$VERSION" \ + --generate-notes \ + ./target/NIOFileServer-*.jar + env: + GH_TOKEN: ${{ github.token }}