From d7956c1c8d3b3b0367e7db0831ef665df9bad790 Mon Sep 17 00:00:00 2001 From: Anatolios Laskaris Date: Wed, 18 Jan 2023 13:36:03 +0200 Subject: [PATCH] fix(ci): Set correct aqua version when creating release-please PRs [fixes FLU-218] (#642) * Bump aqua version * Use base version if snapshot not set * Add SC2086 to shellcheck exclusions * Fix sed statement --- .github/workflows/lint.yml | 2 + .github/workflows/release.yml | 53 ++++++++-- .github/workflows/snapshot.yml | 172 ++++++++++++++++----------------- build.sbt | 10 +- 4 files changed, 141 insertions(+), 96 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8861aafe..9342c287 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -28,6 +28,8 @@ jobs: - name: Lint actions uses: reviewdog/action-actionlint@v1 + env: + SHELLCHECK_OPTS: "-e SC2086" with: reporter: github-pr-check fail_on_error: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7b745f00..2aa5063a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,6 +19,7 @@ jobs: release-created: ${{ steps.release.outputs.release_created }} tag-name: ${{ steps.release.outputs.tag_name }} version: ${{ steps.release.outputs.version }} + pr: ${{ steps.release.outputs['pr'] }} steps: - name: Run release-please @@ -36,6 +37,52 @@ jobs: RELEASE_PLEASE_OUTPUT: ${{ toJSON(steps.release.outputs) }} run: echo "${RELEASE_PLEASE_OUTPUT}" | jq + bump-version: + if: needs.release-please.outputs.pr != null + runs-on: ubuntu-latest + needs: + - release-please + + permissions: + contents: write + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: ${{ fromJson(needs.release-please.outputs.pr).headBranchName }} + + - name: Get aqua version + id: version + run: | + version="$(jq -r '.[]' .github/release-please/manifest.json)" + echo "version=${version}" >> $GITHUB_OUTPUT + + - name: Set version in build.sbt + run: | + sed -i 's/aquaVersion :=.*/aquaVersion = "${{ steps.version.outputs.version }}"/g' build.sbt + + - name: Set cli version + run: npm version ${{ steps.version.outputs.version }} + working-directory: cli/cli-npm + + - name: Set api version + run: npm version ${{ steps.version.outputs.version }} + working-directory: api/aqua-api-npm + + - name: Set lsp version + run: npm version ${{ steps.version.outputs.version }} + working-directory: language-server/language-server-api-npm + + - name: Commit version bump + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "chore: Bump aqua version to ${{ steps.version.outputs.version }}" + branch: ${{ fromJson(needs.release-please.outputs.pr).headBranchName }} + commit_user_name: fluencebot + commit_user_email: devops@fluence.one + commit_author: fluencebot + compile: if: needs.release-please.outputs.release-created runs-on: builder @@ -54,18 +101,12 @@ jobs: - name: JS CLI build run: sbt cliJS/fullLinkJS - env: - BUILD_NUMBER: ${{ needs.release-please.outputs.version}} - name: JS API build run: sbt aqua-api/fullLinkJS - env: - BUILD_NUMBER: ${{ needs.release-please.outputs.version}} - name: JS LSP build run: sbt language-server-api/fullLinkJS - env: - BUILD_NUMBER: ${{ needs.release-please.outputs.version}} - name: Upload aqua-cli artifact uses: actions/upload-artifact@v3 diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index 7affdf7f..d553d3a8 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -14,7 +14,7 @@ on: outputs: aqua-version: description: "@fluencelabs/aqua version" - value: ${{ jobs.aqua.outputs.version }} + value: ${{ jobs.aqua-cli.outputs.version }} aqua-lsp-version: description: "@fluencelabs/aqua-language-server-api version" value: ${{ jobs.aqua-lsp.outputs.version }} @@ -49,41 +49,41 @@ jobs: with: apps: sbt - - name: JS build + - name: JS CLI build env: - BUILD_NUMBER: ${{ steps.version.outputs.id }} + SNAPSHOT: ${{ steps.version.outputs.id }} run: sbt cliJS/fastOptJS - - name: JS LSP API build + - name: JS LSP build env: - BUILD_NUMBER: ${{ steps.version.outputs.id }} + SNAPSHOT: ${{ steps.version.outputs.id }} run: sbt language-server-api/fastOptJS - - name: JS Aqua API build + - name: JS API build env: - BUILD_NUMBER: ${{ steps.version.outputs.id }} + SNAPSHOT: ${{ steps.version.outputs.id }} run: sbt aqua-api/fastOptJS - - name: Upload aqua-js artifact + - name: Upload aqua-cli artifact uses: actions/upload-artifact@v3 with: - name: aqua-js + name: aqua-cli path: cli/cli/.js/target/scala-*/cli-fastopt.js - - name: Upload aqua-js-lsp artifact + - name: Upload aqua-api artifact uses: actions/upload-artifact@v3 with: - name: aqua-js-lsp - path: language-server/language-server-api/target/scala-*/language-server-api-fastopt.js - - - name: Upload aqua-js-api artifact - uses: actions/upload-artifact@v3 - with: - name: aqua-js-api + name: aqua-api path: api/aqua-api/target/scala-*/aqua-api-fastopt.js - aqua: - name: "Publish @fluencelabs/aqua" + - name: Upload aqua-lsp artifact + uses: actions/upload-artifact@v3 + with: + name: aqua-lsp + path: language-server/language-server-api/target/scala-*/language-server-api-fastopt.js + + aqua-cli: + name: "Publish aqua-cli" runs-on: ubuntu-latest needs: compile @@ -102,10 +102,10 @@ jobs: repository: fluencelabs/aqua ref: ${{ inputs.ref }} - - name: Download aqua-js artifact + - name: Download aqua-cli artifact uses: actions/download-artifact@v3 with: - name: aqua-js + name: aqua-cli - run: mv scala-*/cli-fastopt.js cli/cli-npm/aqua.js @@ -152,70 +152,8 @@ jobs: working-directory: cli/cli-npm id: ${{ steps.version.outputs.id }} - aqua-lsp: - name: "Publish @fluencelabs/aqua-language-server-api" - runs-on: ubuntu-latest - - needs: compile - - outputs: - version: "${{ steps.snapshot.outputs.version }}" - - permissions: - contents: read - id-token: write - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - repository: fluencelabs/aqua - ref: ${{ inputs.ref }} - - - name: Download aqua-js-lsp artifact - uses: actions/download-artifact@v3 - with: - name: aqua-js-lsp - - - run: mv scala-*/language-server-api-fastopt.js language-server/language-server-npm/aqua-lsp-api.js - - - name: Import secrets - uses: hashicorp/vault-action@v2.4.3 - with: - url: https://vault.fluence.dev - path: jwt/github - role: ci - method: jwt - jwtGithubAudience: "https://github.com/fluencelabs" - jwtTtl: 300 - exportToken: false - secrets: | - kv/npm-registry/basicauth/ci token | NODE_AUTH_TOKEN - - - name: Setup node with self-hosted npm registry - uses: actions/setup-node@v3 - with: - node-version: "16" - registry-url: "https://npm.fluence.dev" - cache-dependency-path: "language-server/language-server-npm/package-lock.json" - cache: "npm" - - - run: npm i - working-directory: language-server/language-server-npm - - - name: Generate snapshot version - id: version - uses: fluencelabs/github-actions/generate-snapshot-id@main - - - name: Publish snapshot - id: snapshot - uses: fluencelabs/github-actions/npm-publish-snapshot@main - with: - working-directory: language-server/language-server-npm - id: ${{ steps.version.outputs.id }} - aqua-api: - name: "Publish @fluencelabs/aqua-api" + name: "Publish aqua-api" runs-on: ubuntu-latest needs: compile @@ -234,10 +172,10 @@ jobs: repository: fluencelabs/aqua ref: ${{ inputs.ref }} - - name: Download aqua-js artifact + - name: Download aqua-api artifact uses: actions/download-artifact@v3 with: - name: aqua-js-api + name: aqua-api - run: mv scala-*/aqua-api-fastopt.js api/aqua-api-npm/aqua-api.js @@ -280,3 +218,65 @@ jobs: with: working-directory: api/aqua-api-npm id: ${{ steps.version.outputs.id }} + + aqua-lsp: + name: "Publish aqua-lsp" + runs-on: ubuntu-latest + + needs: compile + + outputs: + version: "${{ steps.snapshot.outputs.version }}" + + permissions: + contents: read + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + repository: fluencelabs/aqua + ref: ${{ inputs.ref }} + + - name: Download aqua-lsp artifact + uses: actions/download-artifact@v3 + with: + name: aqua-lsp + + - run: mv scala-*/language-server-api-fastopt.js language-server/language-server-npm/aqua-lsp-api.js + + - name: Import secrets + uses: hashicorp/vault-action@v2.4.3 + with: + url: https://vault.fluence.dev + path: jwt/github + role: ci + method: jwt + jwtGithubAudience: "https://github.com/fluencelabs" + jwtTtl: 300 + exportToken: false + secrets: | + kv/npm-registry/basicauth/ci token | NODE_AUTH_TOKEN + + - name: Setup node with self-hosted npm registry + uses: actions/setup-node@v3 + with: + node-version: "16" + registry-url: "https://npm.fluence.dev" + cache-dependency-path: "language-server/language-server-npm/package-lock.json" + cache: "npm" + + - run: npm i + working-directory: language-server/language-server-npm + + - name: Generate snapshot version + id: version + uses: fluencelabs/github-actions/generate-snapshot-id@main + + - name: Publish snapshot + id: snapshot + uses: fluencelabs/github-actions/npm-publish-snapshot@main + with: + working-directory: language-server/language-server-npm + id: ${{ steps.version.outputs.id }} diff --git a/build.sbt b/build.sbt index be13e222..7e1d4c02 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ val dottyVersion = "3.1.3" scalaVersion := dottyVersion -val baseAquaVersion = settingKey[String]("base aqua version") +val aquaVersion = "0.9.1" val catsV = "2.8.0" val catsParseV = "0.3.8" @@ -17,9 +17,11 @@ val scribeV = "3.7.1" name := "aqua-hll" val commons = Seq( - baseAquaVersion := "0.9.1", - version := baseAquaVersion.value + "-" + sys.env.getOrElse("BUILD_NUMBER", "SNAPSHOT"), - scalaVersion := dottyVersion, + version := { + val aquaSnapshot = sys.env.getOrElse("SNAPSHOT", "") + if (aquaSnapshot.isEmpty()) aquaVersion else aquaVersion + "-" + aquaSnapshot, + }, + scalaVersion := dottyVersion, libraryDependencies ++= Seq( "com.outr" %%% "scribe" % scribeV, "org.scalatest" %%% "scalatest" % scalaTestV % Test