From d44526c9723f18ac43fe9a947808eec1e0737fe2 Mon Sep 17 00:00:00 2001 From: Arvydas Silanskas Date: Sun, 12 May 2024 13:54:51 +0300 Subject: [PATCH] add tag workflow --- .github/workflows/tag_release.yml | 148 ++++++++++++++++++ language/pom.xml | 1 + .../github/arvyy/islisp/launcher/Main.java | 12 +- 3 files changed, 157 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/tag_release.yml diff --git a/.github/workflows/tag_release.yml b/.github/workflows/tag_release.yml new file mode 100644 index 0000000..571d82c --- /dev/null +++ b/.github/workflows/tag_release.yml @@ -0,0 +1,148 @@ +name: Build ISLISP interpreter +on: + workflow_dispatch: + push: + tags: + - '*' +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + architecture: x64 + cache: 'maven' + - name: Verify checkstyle + run: | + mvn -Dcheckstyle.violationSeverity=warning validate + - name: Test + run: | + mvn test + + create-release: + needs: [test] + runs-on: ubuntu-latest + steps: + - name: Create release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref_name }} + run: | + gh release create "$tag" \ + --repo="$GITHUB_REPOSITORY" \ + --title="${GITHUB_REPOSITORY#*/} ${tag#v}" + + build-jar: + needs: [create-release] + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - uses: graalvm/setup-graalvm@v1 + with: + java-version: '22.0.1' + distribution: 'graalvm' + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Build jar + run: | + mvn -Drevision=${{ github.ref_name }} package + - name: Upload jar to github nightly release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload ${{ github.ref_name }} language/target/islisp.jar --clobber + + build-linux: + needs: [create-release] + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - uses: graalvm/setup-graalvm@v1 + with: + java-version: '22.0.1' + distribution: 'graalvm' + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Build jar + run: | + mvn -Drevision=${{ github.ref_name }}-Pnative -DskipTests=true package + - name: Upload linux binary to github nightly release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + mv launcher/target/islisp islisp-linux + gh release upload nightly islisp-linux --clobber + - uses: actions/upload-artifact@v2 + with: + name: islisp-linux + path: islisp-linux + + build-windows: + needs: [create-release] + runs-on: windows-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - uses: graalvm/setup-graalvm@v1 + with: + java-version: '22.0.1' + distribution: 'graalvm' + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Build jar + run: | + mvn -Drevision=${{ github.ref_name }} -Pnative -DskipTests=true package + - name: Upload windows binary to github nightly release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + mv launcher/target/islisp.exe islisp.exe + gh release upload nightly islisp.exe --clobber + + build-macos: + needs: [create-release] + runs-on: macos-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - uses: graalvm/setup-graalvm@v1 + with: + java-version: '22.0.1' + distribution: 'graalvm' + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Build jar + run: | + mvn -Drevision=${{ github.ref_name }} -Pnative -DskipTests=true package + - name: Upload macos binary to github nightly release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + mv launcher/target/islisp islisp-macos + gh release upload nightly islisp-macos --clobber + + publish-docker: + needs: [build-linux] + runs-on: ubuntu-latest + environment: 'Docker hub' + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v2 + with: + name: islisp-linux + path: . + - uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} + - uses: docker/build-push-action@v3 + with: + context: . + file: ./ghworkflow.Dockerfile + push: true + tags: arvyy/islisp:${{ github.ref_name }} diff --git a/language/pom.xml b/language/pom.xml index a0dc31c..b5ff524 100644 --- a/language/pom.xml +++ b/language/pom.xml @@ -85,6 +85,7 @@ ${project.build.outputDirectory}/com/github/arvyy/islisp/buildinfo/git-islisp-lang.properties git.commit.id.full + git.tags full diff --git a/launcher/src/main/java/com/github/arvyy/islisp/launcher/Main.java b/launcher/src/main/java/com/github/arvyy/islisp/launcher/Main.java index b04881e..5a4fe87 100644 --- a/launcher/src/main/java/com/github/arvyy/islisp/launcher/Main.java +++ b/launcher/src/main/java/com/github/arvyy/islisp/launcher/Main.java @@ -40,10 +40,14 @@ public static void main(String[] args) throws IOException, ParseException { if (commandLine.hasOption(versionOpt)) { var properties = BuildInfo.getBuildProperties(); var pw = new PrintWriter(System.out); - new HelpFormatter().printWrapped(pw, HELP_WIDTH, """ - ISLISP Truffle - Git commit {version} - """.replace("{version}", properties.getProperty("git.commit.id.full"))); + var sb = new StringBuilder("ISLISP Truffle"); + var tag = properties.getProperty("git.tags"); + if (tag != null) { + sb.append(" ").append(tag); + } else { + sb.append("\nGit commit ").append(properties.getProperty("git.commit.id.full")); + } + new HelpFormatter().printWrapped(pw, HELP_WIDTH, sb.toString()); pw.flush(); return; }