diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0774f03..c4c864b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,17 +1,12 @@ name: Release -on: - workflow_dispatch: - inputs: - release_version: - description: Release version - required: false - default: '' +on: workflow_dispatch jobs: - release: - name: Release + pre-release: runs-on: ubuntu-latest + outputs: + release-tag: ${{ steps.latest-tag.outputs.tag }} steps: - name: Check out repository code uses: actions/checkout@v2 @@ -23,25 +18,87 @@ jobs: distribution: 'temurin' java-version: '11' - name: Configure local git - run: | - git config user.name "${{ secrets.GIT_USERNAME }}" + run: >- + git config user.name "${{ secrets.GIT_USERNAME }}" && git config user.email "${{ secrets.GIT_USER_EMAIL }}" - name: Release new version - if: ${{ github.event.inputs.release_version == '' }} - run: | - sbt "release with-defaults" - - name: Release the specified version - if: ${{ github.event.inputs.release_version != '' }} - run: | - sbt "release with-defaults release-version ${{ github.event.inputs.release_version }}" + run: sbt preRelease - name: Latest tag uses: actions-ecosystem/action-get-latest-tag@v1 - id: get-latest-tag + id: latest-tag - name: Github Release + id: gh_release uses: softprops/action-gh-release@v1 with: - tag_name: ${{ steps.get-latest-tag.outputs.tag }} + tag_name: ${{ steps.latest-tag.outputs.tag }} body_path: CHANGELOG.md files: | target/scala-3.1.2/polystat.jar - polystat-x86_64-pc-linux + build-binaries: + needs: pre-release + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest] + include: + - os: ubuntu-latest + uploaded_filename: polystat-x86_64-pc-linux + local_path: polystat + - os: windows-latest + uploaded_filename: polystat-x86_64-pc-win32.exe + local_path: polystat.exe + steps: + - name: Check out repository code + uses: actions/checkout@v2 + with: + token: ${{ secrets.GIT_TOKEN }} + - name: Configure local git + run: >- + git config user.name "${{ secrets.GIT_USERNAME }}" && + git config user.email "${{ secrets.GIT_USER_EMAIL }}" + - run: git pull --no-rebase + - uses: olafurpg/setup-scala@v13 + - name: Set up Visual Studio shell + uses: egor-tensin/vs-shell@v2 + if: ${{ matrix.os == 'windows-latest' }} + - name: build native image (windows) + if: ${{ matrix.os == 'windows-latest' }} + shell: cmd + run: >- + echo %PATH% && + sbt nativeImage && + copy target\native-image\polystat-cli.exe ${{ matrix.uploaded_filename }} && + tree + - name: build native image (linux) + if: ${{ matrix.os != 'windows-latest' }} + shell: bash + run: | + echo $PATH + sbt "nativeImageCopy ${{ matrix.uploaded_filename }}" nativeImageRun + - name: Upload release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ needs.pre-release.outputs.release-tag }} + files: ${{ matrix.uploaded_filename }} + post-release: + needs: build-binaries + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v2 + with: + token: ${{ secrets.GIT_TOKEN }} + - name: Configure local git + run: | + git config user.name "${{ secrets.GIT_USERNAME }}" + git config user.email "${{ secrets.GIT_USER_EMAIL }}" + - name: setup JDK + uses: actions/setup-java@v2 + with: + distribution: 'temurin' + java-version: '11' + - run: git pull --no-rebase + - name: Run post-release steps + run: | + sbt postRelease diff --git a/CHANGELOG.md b/CHANGELOG.md index 13bfb1e..43a887a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,3 @@ -## Polystat v0.1.1 +## Polystat v0.1.2 -In this release, the CI was updated to produce native Linux binaries using GraalVM Native Image. \ No newline at end of file +In this release, the CI was updated to produce native binaries for Windows and Linux. diff --git a/build.sbt b/build.sbt index 0a30f8f..07774eb 100644 --- a/build.sbt +++ b/build.sbt @@ -48,6 +48,8 @@ nativeImageOptions ++= Seq( "--initialize-at-run-time=scala.tools.nsc.ast.parser.ParsersCommon", "--static", "--no-fallback", + "--enable-http", + "--enable-https", "--verbose", ) @@ -55,21 +57,46 @@ scalacOptions ++= Seq( "-Wunused:all" ) -releaseProcess := Seq[ReleaseStep]( - checkSnapshotDependencies, - inquireVersions, - runClean, - runTest, - setReleaseVersion, - commitReleaseVersion, - tagRelease, - releaseStepTask(assembly), - releaseStepInputTask(nativeImageCopy, "polystat-x86_64-pc-linux"), - releaseStepInputTask(nativeImageRun), - setNextVersion, - commitNextVersion, - pushChanges, -) +commands += Command.command("preRelease") { state => + val newState = Project + .extract(state) + .appendWithSession( + Seq( + releaseProcess := Seq( + checkSnapshotDependencies, + inquireVersions, + runClean, + runTest, + setReleaseVersion, + releaseStepTask(assembly), + commitReleaseVersion, + tagRelease, + pushChanges, + ) + ), + state, + ) + + Command.process("release with-defaults", newState) +} + +commands += Command.command("postRelease") { state => + val newState = Project + .extract(state) + .appendWithSession( + Seq( + releaseProcess := Seq( + inquireVersions, + setNextVersion, + commitNextVersion, + pushChanges, + ) + ), + state, + ) + + Command.process("release with-defaults", newState) +} val githubWorkflowScalas = List("3.1.2")