From 17e420f657c4b91826a9f82073a0dd3a6e05faa5 Mon Sep 17 00:00:00 2001 From: Anatolios Laskaris Date: Tue, 7 Feb 2023 18:58:04 +0200 Subject: [PATCH] chore(ci): Add release-please (#100) * Add release-please * Fix * Fix * No to wasmer * use older rust-toolchain with compatible error messages --------- Co-authored-by: Valery Antopol --- .github/actionlint.yaml | 3 + .github/release-please/config.json | 17 ++ .github/release-please/manifest.json | 3 + .github/renovate.json | 26 ++- .../workflows/{marine-rs-sdk.yml => ci.yml} | 10 +- .github/workflows/lint.yml | 35 ++++ .github/workflows/publish_release.yml | 49 ----- .github/workflows/release.yml | 173 ++++++++++++++++++ Cargo.toml | 2 +- crates/main/Cargo.toml | 2 +- crates/main/src/lib.rs | 2 +- crates/marine-macro-impl/Cargo.toml | 2 +- crates/marine-macro-impl/src/lib.rs | 2 +- crates/marine-macro/Cargo.toml | 2 +- crates/marine-macro/src/lib.rs | 2 +- crates/timestamp-macro/Cargo.toml | 2 +- rust-toolchain.toml | 2 +- src/lib.rs | 2 +- 18 files changed, 268 insertions(+), 68 deletions(-) create mode 100644 .github/actionlint.yaml create mode 100644 .github/release-please/config.json create mode 100644 .github/release-please/manifest.json rename .github/workflows/{marine-rs-sdk.yml => ci.yml} (83%) create mode 100644 .github/workflows/lint.yml delete mode 100644 .github/workflows/publish_release.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml new file mode 100644 index 0000000..be1bfdc --- /dev/null +++ b/.github/actionlint.yaml @@ -0,0 +1,3 @@ +self-hosted-runner: + labels: + - builder diff --git a/.github/release-please/config.json b/.github/release-please/config.json new file mode 100644 index 0000000..284a6de --- /dev/null +++ b/.github/release-please/config.json @@ -0,0 +1,17 @@ +{ + "bootstrap-sha": "9e75f94c6a3ec37b6dd945435c1d16ecfb4714a4", + "release-type": "simple", + "bump-minor-pre-major": true, + "bump-patch-for-minor-pre-major": true, + "packages": { + ".": { + "component": "marine-rs-sdk", + "extra-files": [ + "crates/main/src/lib.rs", + "crates/marine-macro-impl/src/lib.rs", + "marine-macro/src/lib.rs", + "src/lib.rs" + ] + } + } +} diff --git a/.github/release-please/manifest.json b/.github/release-please/manifest.json new file mode 100644 index 0000000..13708fa --- /dev/null +++ b/.github/release-please/manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.7.1" +} diff --git a/.github/renovate.json b/.github/renovate.json index 5fec988..d797aec 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -4,9 +4,25 @@ "config:base", ":semanticCommitTypeAll(chore)" ], - "enabledManagers": ["cargo", "npm", "github-actions"], + "enabledManagers": ["cargo", "github-actions"], "schedule": "every weekend", "packageRules": [ + { + "matchManagers": ["cargo"], + "matchPackagePatterns": [ + "fluence-.*", + "avm-server", + "air-intepreter-wasm", + "marine-.*" + ], + "semanticCommitType": "fix", + "semanticCommitScope": "deps", + "schedule": "at any time" + }, + { + "matchPackagePatterns": ["^@wasmer", "^wasmer", "^wasm-bindgen"], + "enabled": false + }, { "matchDepTypes": ["devDependencies"], "prPriority": -1 @@ -16,14 +32,8 @@ "prConcurrentLimit": 1 }, { - "matchManagers": [ "github-actions" ], - "automerge": true, - "automergeType": "branch", + "matchManagers": ["github-actions"], "prPriority": 1 - }, - { - "matchPackagePatterns": ["^@wasmer", "^wasmer", "^wasm-bindgen"], - "enabled": false } ] } diff --git a/.github/workflows/marine-rs-sdk.yml b/.github/workflows/ci.yml similarity index 83% rename from .github/workflows/marine-rs-sdk.yml rename to .github/workflows/ci.yml index 6aa650e..3d3e2f2 100644 --- a/.github/workflows/marine-rs-sdk.yml +++ b/.github/workflows/ci.yml @@ -1,10 +1,18 @@ -name: "marine-rs-sdk" +name: "ci" on: pull_request: + paths-ignore: + - "**.md" + - ".github/**" + - "!.github/workflows/ci.yml" push: branches: - "master" + paths-ignore: + - "**.md" + - ".github/**" + - "!.github/workflows/ci.yml" concurrency: group: "${{ github.workflow }}-${{ github.ref }}" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..b3374a5 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,35 @@ +name: lint + +on: + pull_request: + types: + - opened + - edited + - synchronize + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + +jobs: + pr: + name: Validate PR title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + reviewdog: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Lint actions + uses: reviewdog/action-actionlint@v1 + env: + SHELLCHECK_OPTS: "-e SC2086 -e SC2207 -e SC2128" + with: + reporter: github-pr-check + fail_on_error: true diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml deleted file mode 100644 index 7ce257c..0000000 --- a/.github/workflows/publish_release.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: "publish-release" - -on: - workflow_dispatch: - -jobs: - npm-publish: - name: "Publish release" - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Setup rust toolchain - uses: actions-rust-lang/setup-rust-toolchain@v1 - - - name: Install jq - run: sudo apt-get update && sudo apt-get --yes --force-yes install jq - - - name: Install cargo-workspaces - run: cargo install cargo-workspaces - - - name: Login to crates.io - run: cargo login ${{ secrets.CRATES_IO_TOKEN }} - - - name: Save marine-rs-sdk's crate version to env - run: | - set -x - PKG_NAME=marine-rs-sdk - VERSION=$(cargo ws list -l | grep "$PKG_NAME\s" | head -n1 | awk '{ print $2 }') - echo "VERSION=$VERSION" | tee -a $GITHUB_ENV - echo "PKG_NAME=$PKG_NAME" | tee -a $GITHUB_ENV - - - name: Publish to crates.io - run: cargo ws publish --no-git-commit --from-git --skip-published --yes - - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ env.VERSION }} - release_name: Marine Rust SDK ${{ env.VERSION }} - body: | - - [${{ env.VERSION }} @ crates.io](https://crates.io/crates/${{ env.PKG_NAME }}/${{ env.VERSION }}) - draft: false - prerelease: false diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..72c0014 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,173 @@ +name: "release-please" + +on: + push: + branches: + - "master" + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + +jobs: + release-please: + runs-on: ubuntu-latest + + outputs: + release-created: ${{ steps.release.outputs.release_created }} + pr: ${{ steps.release.outputs.pr }} + + steps: + - name: Run release-please + id: release + uses: google-github-actions/release-please-action@v3 + with: + token: ${{ secrets.FLUENCEBOT_RELEASE_PLEASE_PAT }} + command: manifest + config-file: .github/release-please/config.json + manifest-file: .github/release-please/manifest.json + + - name: Show output from release-please + if: steps.release.outputs.releases_created + env: + RELEASE_PLEASE_OUTPUT: ${{ toJSON(steps.release.outputs) }} + run: echo "${RELEASE_PLEASE_OUTPUT}" | jq + + bump-version: + if: needs.release-please.outputs.pr != null + runs-on: builder + needs: + - release-please + + permissions: + contents: write + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: ${{ fromJson(needs.release-please.outputs.pr).headBranchName }} + token: ${{ secrets.FLUENCEBOT_RELEASE_PLEASE_PAT }} + + - name: Setup Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Get version + id: version + run: | + version="$(jq -r '.[]' .github/release-please/manifest.json)" + echo "version=${version}" >> $GITHUB_OUTPUT + + - name: Install cargo-workspaces + uses: baptiste0928/cargo-install@v1.3.0 + with: + crate: cargo-workspaces + + - name: Set version + run: | + cargo ws version \ + --force '*' \ + --no-git-commit \ + --all \ + --exact \ + --yes \ + custom ${{ steps.version.outputs.version }} + + - name: Commit version bump + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "chore: Bump 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 + + crates: + if: needs.release-please.outputs.release-created + runs-on: builder + needs: + - release-please + + permissions: + contents: write + id-token: write + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - 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/crates.io/fluencebot token | CARGO_REGISTRY_TOKEN + + - name: Setup Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Install cargo-workspaces + uses: baptiste0928/cargo-install@v1.3.0 + with: + crate: cargo-workspaces + + - name: Publish to crates.io + run: | + cargo ws publish \ + --no-git-commit \ + --allow-dirty \ + --from-git \ + --skip-published \ + --yes + + slack: + if: always() + name: "Notify" + runs-on: ubuntu-latest + + needs: + - release-please + - crates + + permissions: + contents: read + id-token: write + + steps: + - uses: lwhiteley/dependent-jobs-result-check@v1 + id: status + with: + statuses: failure + dependencies: ${{ toJSON(needs) }} + + - name: Log output + run: | + echo "statuses:" "${{ steps.status.outputs.statuses }}" + echo "jobs:" "${{ steps.status.outputs.jobs }}" + echo "found any?:" "${{ steps.status.outputs.found }}" + + - 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/slack/release-please webhook | SLACK_WEBHOOK_URL + + - uses: ravsamhq/notify-slack-action@v2 + if: steps.status.outputs.found == 'true' + with: + status: "failure" + notification_title: "*{workflow}* has {status_message}" + message_format: "${{ steps.status.outputs.jobs }} {status_message} in <{repo_url}|{repo}>" + footer: "<{run_url}>" diff --git a/Cargo.toml b/Cargo.toml index cc3c4a0..0bed5c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "marine-rs-sdk" -version = "0.7.1" # remember to update html_root_url +version = "0.7.1" description = "Fluence backend SDK for developing backend applications for the Fluence network" documentation = "https://docs.rs/fluence" repository = "https://github.com/fluencelabs/marine-rs-sdk" diff --git a/crates/main/Cargo.toml b/crates/main/Cargo.toml index 11ad365..6bd4463 100644 --- a/crates/main/Cargo.toml +++ b/crates/main/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "marine-rs-sdk-main" -version = "0.7.1" # remember to update html_root_url +version = "0.7.1" edition = "2018" description = "Contains logger, allocators and several other modules for marine-rs-sdk" documentation = "https://docs.rs/marine-rs-sdk-main" diff --git a/crates/main/src/lib.rs b/crates/main/src/lib.rs index 02584f0..a8d572e 100644 --- a/crates/main/src/lib.rs +++ b/crates/main/src/lib.rs @@ -19,7 +19,7 @@ #![allow(clippy::missing_safety_doc)] #![allow(clippy::needless_doctest_main)] -#![doc(html_root_url = "https://docs.rs/marine-rs-sdk-main/0.7.1")] +#![doc(html_root_url = "https://docs.rs/marine-rs-sdk-main/0.7.1")] // x-release-please-version #![deny( dead_code, nonstandard_style, diff --git a/crates/marine-macro-impl/Cargo.toml b/crates/marine-macro-impl/Cargo.toml index 331ad39..bf1c56d 100644 --- a/crates/marine-macro-impl/Cargo.toml +++ b/crates/marine-macro-impl/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "marine-macro-impl" -version = "0.7.1" # remember to update html_root_url +version = "0.7.1" edition = "2018" description = "Implementation of the `#[marine]` macro" documentation = "https://docs.rs/fluence/marine-macro-impl" diff --git a/crates/marine-macro-impl/src/lib.rs b/crates/marine-macro-impl/src/lib.rs index f380fbd..0747f06 100644 --- a/crates/marine-macro-impl/src/lib.rs +++ b/crates/marine-macro-impl/src/lib.rs @@ -14,7 +14,7 @@ * limitations under the License. */ -#![doc(html_root_url = "https://docs.rs/marine-macro-impl/0.7.1")] +#![doc(html_root_url = "https://docs.rs/marine-macro-impl/0.7.1")] // x-release-please-version #![deny( dead_code, nonstandard_style, diff --git a/crates/marine-macro/Cargo.toml b/crates/marine-macro/Cargo.toml index 32386cb..707b7d6 100644 --- a/crates/marine-macro/Cargo.toml +++ b/crates/marine-macro/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "marine-macro" -version = "0.7.1" # remember to update html_root_url +version = "0.7.1" edition = "2018" description = "Definition of the `#[marine]` macro" documentation = "https://docs.rs/fluence/marine-macro" diff --git a/crates/marine-macro/src/lib.rs b/crates/marine-macro/src/lib.rs index bc4314b..3c6c2ed 100644 --- a/crates/marine-macro/src/lib.rs +++ b/crates/marine-macro/src/lib.rs @@ -50,7 +50,7 @@ //! //! ``` -#![doc(html_root_url = "https://docs.rs/marine-macro/0.7.1")] +#![doc(html_root_url = "https://docs.rs/marine-macro/0.7.1")] // x-release-please-version #![deny( dead_code, nonstandard_style, diff --git a/crates/timestamp-macro/Cargo.toml b/crates/timestamp-macro/Cargo.toml index 509702b..9ec8c16 100644 --- a/crates/timestamp-macro/Cargo.toml +++ b/crates/timestamp-macro/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "marine-timestamp-macro" -version = "0.7.1" # remember to update html_root_url +version = "0.7.1" edition = "2018" description = "Definition of the `#[build_timestamp]` macro" documentation = "https://docs.rs/fluence/marine-timestamp-macro" diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 8a238f4..5356dac 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "stable" +channel = "stable-2022-09-22" targets = [ "x86_64-unknown-linux-gnu", "x86_64-apple-darwin", "wasm32-wasi" ] diff --git a/src/lib.rs b/src/lib.rs index be83d11..46b002e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -55,7 +55,7 @@ //! pub fn curl_get(url: String) -> String; //! } //! ``` -#![doc(html_root_url = "https://docs.rs/sdk/0.7.1")] +#![doc(html_root_url = "https://docs.rs/sdk/0.7.1")] // x-release-please-version #![deny( dead_code, nonstandard_style,