diff --git a/.github/actions/shared/action.yml b/.github/actions/shared/action.yml index 3ebf0215f..2230231d8 100644 --- a/.github/actions/shared/action.yml +++ b/.github/actions/shared/action.yml @@ -1,4 +1,5 @@ name: 'Shared action' +description: 'Frees runner disk space, installs protobuf and caches the cargo registry' runs: using: "composite" steps: @@ -13,12 +14,13 @@ runs: sudo rm -rf /usr/local/share/boost sudo rm -rf /opt/hostedtoolcache sudo rm -rf "$AGENT_TOOLSDIRECTORY" - sudo apt-get remove -y 'php.*' --fix-missing - sudo apt-get remove -y '^mongodb-.*' --fix-missing - sudo apt-get remove -y '^mysql-.*' --fix-missing - sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri --fix-missing - sudo apt-get remove -y google-cloud-sdk --fix-missing - sudo apt-get remove -y google-cloud-cli --fix-missing + # Runner images differ in what they ship; remove only what is installed. + for pattern in 'php.*' '^mongodb-.*' '^mysql-.*'; do + sudo apt-get remove -y "$pattern" --fix-missing || echo "nothing matches $pattern" + done + for pkg in azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri google-cloud-sdk google-cloud-cli; do + if dpkg -s "$pkg" >/dev/null 2>&1; then sudo apt-get remove -y "$pkg" --fix-missing; fi + done sudo apt-get autoremove -y sudo apt-get clean df -h @@ -26,7 +28,7 @@ runs: # Free GitHub Actions Environment Disk Space - name: Maximize Build Space - uses: jlumbroso/free-disk-space@main + uses: jlumbroso/free-disk-space@36e9a5af4eddb91fc11aec4c6f6f79b3cc0cb523 # main with: tool-cache: false large-packages: false @@ -45,7 +47,7 @@ runs: # Steps taken from https://github.com/actions/cache/blob/master/examples.md#rust---cargo - name: Cache cargo registry - uses: actions/cache@v4 + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: | ~/.cargo/registry diff --git a/.github/dependabot.yml b/.github/dependabot.yml index ece6934ed..1ee0050ff 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,6 +5,9 @@ updates: schedule: interval: "daily" - package-ecosystem: github-actions - directory: "/" + # "/" covers the workflows only; the composite action pins its own actions. + directories: + - "/" + - "/.github/actions/shared" schedule: interval: daily diff --git a/.github/workflows/clippy-checks.yml b/.github/workflows/clippy-checks.yml index e17d68e5f..86cdb14b5 100644 --- a/.github/workflows/clippy-checks.yml +++ b/.github/workflows/clippy-checks.yml @@ -6,30 +6,28 @@ on: branches: - main +permissions: + contents: read + jobs: clippy-checks: - runs-on: ubuntu-latest + # The bundled RocksDB (librocksdb-sys 0.11) does not build with the GCC of newer images. + runs-on: ubuntu-24.04 steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 - name: Free up Space and Installation uses: ./.github/actions/shared - name: Clippy -- Main - uses: actions-rs/cargo@v1 - with: - command: clippy - # `manual_inspect` (clippy 1.81) fires inside the `#[pallet::pallet]` expansion of our - # polkadot-sdk fork; the `deny(warnings)` pallets cannot allow it from the outside. - args: --release --all-features -- -W clippy::all -A clippy::style -A clippy::manual_inspect -A forgetting_copy_types -A forgetting_references + # `manual_inspect` (clippy 1.81) fires inside the `#[pallet::pallet]` expansion of our + # polkadot-sdk fork; the `deny(warnings)` pallets cannot allow it from the outside. + run: cargo clippy --release --all-features -- -W clippy::all -A clippy::style -A clippy::manual_inspect -A forgetting_copy_types -A forgetting_references - name: Clippy -- All Targets (except integration) - uses: actions-rs/cargo@v1 - with: - command: clippy - # We are a bit more forgiving when it comes to the code in tests and only check for correctness - args: --release --workspace --all-features --all-targets --exclude runtime-integration-tests -- -A clippy::all -W clippy::correctness -A forgetting_copy_types -A forgetting_references + # We are a bit more forgiving when it comes to the code in tests and only check for correctness + run: cargo clippy --release --workspace --all-features --all-targets --exclude runtime-integration-tests -- -A clippy::all -W clippy::correctness -A forgetting_copy_types -A forgetting_references # Disabled until we move to crates.io and fix runtime-integration-tests. # - name: Clippy -- Integration diff --git a/.github/workflows/link-check.yml b/.github/workflows/link-check.yml index 02ee084d0..5b54e0827 100644 --- a/.github/workflows/link-check.yml +++ b/.github/workflows/link-check.yml @@ -8,12 +8,15 @@ on: branches: - main +permissions: + contents: read + jobs: markdown-link-check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 - - uses: gaurav-nelson/github-action-markdown-link-check@v1 + - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 + - uses: gaurav-nelson/github-action-markdown-link-check@5c5dfc0ac2e225883c0e5f03a85311ec2830d368 # v1 with: use-quiet-mode: 'yes' config-file: '.github/workflows/mlc_config.json' diff --git a/.github/workflows/migration-tests.yml b/.github/workflows/migration-tests.yml index 2d2c5a5eb..51b0f75cf 100644 --- a/.github/workflows/migration-tests.yml +++ b/.github/workflows/migration-tests.yml @@ -3,7 +3,7 @@ name: Migration Tests # The PEN -> Base migration stack lives outside the Rust workspace: the # Foundry contracts and the three TypeScript daemons. `test-code.yml` covers # the pallet through `cargo test`; this job covers everything else, so a -# green check on the PR means the suites the review log cites actually ran. +# green check on the PR means the contract and daemon suites actually ran. on: pull_request: @@ -17,6 +17,9 @@ on: branches: - main +permissions: + contents: read + jobs: contracts: name: Foundry (contracts) @@ -25,11 +28,11 @@ jobs: run: working-directory: contracts steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 with: submodules: recursive - - uses: foundry-rs/foundry-toolchain@v1 + - uses: foundry-rs/foundry-toolchain@908c540300062bd5a7e473851cdb4282204cee09 # v1.9.1 with: version: stable @@ -50,9 +53,9 @@ jobs: run: working-directory: ${{ matrix.package }} steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 - - uses: actions/setup-node@v4 + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: 20 cache: npm diff --git a/.github/workflows/release-node.yml b/.github/workflows/release-node.yml index 4b0417a8d..d2fa7632b 100644 --- a/.github/workflows/release-node.yml +++ b/.github/workflows/release-node.yml @@ -8,6 +8,9 @@ on: branches: - 'main' +permissions: + contents: read + jobs: release_check: # This job will only run if: @@ -21,7 +24,7 @@ jobs: steps: - name: Check out repository code - uses: actions/checkout@v5 + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 - name: Get Node Version id: get-version @@ -30,6 +33,10 @@ jobs: echo "version=${vers}" >> "$GITHUB_OUTPUT" - name: trigger gitlab + env: + GITLAB_TRIGGER: ${{ secrets.GITLAB_TRIGGER }} + PROJECT_ID: ${{ secrets.PROJECT_ID }} + VERSION: ${{ steps.get-version.outputs.version }} run: | - ls ${{ github.workspace }} - curl -X POST -F "token=${{ secrets.GITLAB_TRIGGER }}" -F "ref=development" -F "variables[PREPCOMPILE]=Y" -F "variables[COMPILE]=Y" -F "variables[COMPILEMOONBEAM]=N" -F "variables[DOCKER]=Y" -F "variables[DOCKERAMP]=Y" -F "variables[DEBIAN]=Y" -F "variables[TEMPUPLOAD]=Y" -F "variables[DOWNUPLOAD]=Y" -F "variables[PRODUPLOAD]=Y" -F "variables[VERSION]=${{ steps.get-version.outputs.version }}" https://gitlab.com/api/v4/projects/${{ secrets.PROJECT_ID }}/trigger/pipeline \ No newline at end of file + ls "$GITHUB_WORKSPACE" + curl -X POST -F "token=$GITLAB_TRIGGER" -F "ref=development" -F "variables[PREPCOMPILE]=Y" -F "variables[COMPILE]=Y" -F "variables[COMPILEMOONBEAM]=N" -F "variables[DOCKER]=Y" -F "variables[DOCKERAMP]=Y" -F "variables[DEBIAN]=Y" -F "variables[TEMPUPLOAD]=Y" -F "variables[DOWNUPLOAD]=Y" -F "variables[PRODUPLOAD]=Y" -F "variables[VERSION]=$VERSION" "https://gitlab.com/api/v4/projects/$PROJECT_ID/trigger/pipeline" \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c2ad0f5b7..041284b80 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,10 +3,11 @@ # # The wasm that goes into a runtime-upgrade referendum must be reproducible: # anyone with the same commit, srtool image and build options must arrive at -# the same hash. This job builds the runtime inside the pinned srtool image -# (rustc matching rust-toolchain.toml), records the srtool/subwasm report, -# and — when a release tag is known — attaches the compressed wasm and the -# report to the GitHub release for that tag. +# the same hash. The build job builds the runtime inside the srtool image +# pinned by digest (rustc matching rust-toolchain.toml) and records the +# srtool/subwasm report; when a release tag is known, the publish job (the +# only one with write access) attaches the compressed wasm and the report to +# the GitHub release for that tag. # # Usage: # * Push a tag `pendulum-release-` (or `amplitude-release-`) on @@ -33,29 +34,44 @@ on: required: false default: "" +permissions: + contents: read + jobs: build: name: srtool build runs-on: ubuntu-latest - permissions: - contents: write + outputs: + chain: ${{ steps.meta.outputs.chain }} + tag: ${{ steps.meta.outputs.tag }} + sha: ${{ steps.commit.outputs.sha }} env: # srtool passes this to cargo. The runtimes keep CheckMetadataHash in # their signed extensions; without the embedded metadata hash every # transaction signed with it (mode 1, as Ledger signs) is rejected. BUILD_OPTS: --features metadata-hash + # The srtool image (rustc 1.81.0), pinned by digest so a moved tag cannot + # change the build. + SRTOOL_IMAGE_TAG: 1.81.0-0.17.0@sha256:9cff8845b2640c89524f4df6f176c43d55b02d0e75ba58dd517d501b33e26f1a steps: - name: Resolve chain and tag id: meta shell: bash + env: + INPUT_TAG: ${{ github.event.inputs.tag }} + INPUT_CHAIN: ${{ github.event.inputs.chain }} run: | - if [ "${{ github.event_name }}" = "push" ]; then - TAG="${{ github.ref_name }}" + if [ "$GITHUB_EVENT_NAME" = "push" ]; then + TAG="$GITHUB_REF_NAME" CHAIN="${TAG%%-release-*}" else - TAG="${{ github.event.inputs.tag }}" - CHAIN="${{ github.event.inputs.chain }}" + TAG="$INPUT_TAG" + CHAIN="$INPUT_CHAIN" fi + # A dispatched tag is free text; it goes into step outputs and log lines. + case "$TAG" in + *[!A-Za-z0-9._-]*) echo "::error::a release tag may contain only letters, digits, '.', '_' and '-'"; exit 1 ;; + esac case "$CHAIN" in pendulum|amplitude) ;; *) echo "cannot derive the chain from '$TAG'; expected -release-"; exit 1 ;; @@ -67,12 +83,14 @@ jobs: fi echo "chain=$CHAIN" >> "$GITHUB_OUTPUT" echo "tag=$TAG" >> "$GITHUB_OUTPUT" - echo "ref=${TAG:-${{ github.ref }}}" >> "$GITHUB_OUTPUT" + echo "ref=${TAG:-$GITHUB_REF}" >> "$GITHUB_OUTPUT" - - uses: actions/checkout@v5 + - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 with: ref: ${{ steps.meta.outputs.ref }} fetch-depth: 0 + # The srtool container mounts the workspace; keep the token out of it. + persist-credentials: false - name: Check the commit to build id: commit @@ -90,11 +108,12 @@ jobs: - name: Build with srtool id: srtool - uses: chevdor/srtool-actions@v0.9.2 + uses: chevdor/srtool-actions@48e9baed50ca414936dfac59d34d8b9bbe581abd # v0.9.2 with: package: ${{ steps.meta.outputs.chain }}-runtime runtime_dir: runtime/${{ steps.meta.outputs.chain }} - tag: "1.81.0" + # The action runs :, so the tag carries the digest. + tag: ${{ env.SRTOOL_IMAGE_TAG }} - name: Check that the metadata hash is embedded shell: bash @@ -114,24 +133,29 @@ jobs: - name: Record the srtool report shell: bash + env: + CHAIN: ${{ steps.meta.outputs.chain }} + SHA: ${{ steps.commit.outputs.sha }} + SRTOOL_JSON: ${{ steps.srtool.outputs.json }} + WASM_COMPRESSED: ${{ steps.srtool.outputs.wasm_compressed }} run: | - echo '${{ steps.srtool.outputs.json }}' | jq . > srtool-${{ steps.meta.outputs.chain }}.json + printf '%s\n' "$SRTOOL_JSON" | jq . > "srtool-$CHAIN.json" { - echo "## ${{ steps.meta.outputs.chain }} runtime — srtool build" + echo "## $CHAIN runtime — srtool build" echo - echo "Commit: \`${{ steps.commit.outputs.sha }}\` · srtool image: \`paritytech/srtool:1.81.0\` · BUILD_OPTS: \`$BUILD_OPTS\` · reproduce with the same commit, image and BUILD_OPTS." + echo "Commit: \`$SHA\` · srtool image: \`paritytech/srtool:$SRTOOL_IMAGE_TAG\` · BUILD_OPTS: \`$BUILD_OPTS\` · reproduce with the same commit, image and BUILD_OPTS." echo echo "For \`parachainSystem.authorizeUpgrade\` use **\`blake2_256\`** below (the code hash the chain recomputes from the wasm at enactment); \`proposal_hash\` is the preimage hash of a \`system.setCode\` call and \`parachain_authorize_upgrade_hash\` is derived from the authorize call — neither is the value to authorize." echo echo '```json' - jq '.runtimes.compressed.subwasm // .' srtool-${{ steps.meta.outputs.chain }}.json + jq '.runtimes.compressed.subwasm // .' "srtool-$CHAIN.json" echo '```' } > release-notes.md cat release-notes.md >> "$GITHUB_STEP_SUMMARY" - cp "${{ steps.srtool.outputs.wasm_compressed }}" ./${{ steps.meta.outputs.chain }}_runtime.compact.compressed.wasm - sha256sum ./${{ steps.meta.outputs.chain }}_runtime.compact.compressed.wasm | tee -a release-notes.md + cp "$WASM_COMPRESSED" "./${CHAIN}_runtime.compact.compressed.wasm" + sha256sum "./${CHAIN}_runtime.compact.compressed.wasm" | tee -a release-notes.md - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: ${{ steps.meta.outputs.chain }}-runtime-${{ steps.commit.outputs.sha }} path: | @@ -140,13 +164,52 @@ jobs: release-notes.md if-no-files-found: error - - name: Publish the GitHub release - if: steps.meta.outputs.tag != '' - uses: softprops/action-gh-release@v2 + publish: + name: Publish the GitHub release + needs: build + if: needs.build.outputs.tag != '' + runs-on: ubuntu-latest + # A second run for the same tag waits for the first, then finds its assets. + concurrency: + group: publish-${{ needs.build.outputs.tag }} + cancel-in-progress: false + permissions: + contents: write + steps: + - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 with: - tag_name: ${{ steps.meta.outputs.tag }} - name: ${{ steps.meta.outputs.tag }} + name: ${{ needs.build.outputs.chain }}-runtime-${{ needs.build.outputs.sha }} + + # A published runtime is never rebuilt in place: a later build of the same + # tag (other build options or image) need not match the hash enacted on + # chain. Publishing again needs the old assets removed by hand. + - name: Refuse to change a release that already has assets + shell: bash + env: + GH_TOKEN: ${{ github.token }} + TAG: ${{ needs.build.outputs.tag }} + run: | + # The lookup the release action makes; any error but a missing release fails the step. + if REL="$(gh api "repos/$GITHUB_REPOSITORY/releases/tags/$TAG")"; then + ASSETS="$(jq -r '[.assets[].name] | join(" ")' <<<"$REL")" + elif [ "$(jq -r '.status? // empty' <<<"$REL" 2>/dev/null)" = 404 ]; then + ASSETS="" + else + echo "::error::could not look up the release for $TAG" + exit 1 + fi + if [ -n "$ASSETS" ]; then + echo "::error::release $TAG already has assets ($ASSETS); refusing to change it" + exit 1 + fi + + - uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2.6.2 + with: + tag_name: ${{ needs.build.outputs.tag }} + name: ${{ needs.build.outputs.tag }} body_path: release-notes.md + # Never delete an attached asset, even one another run added after the check. + overwrite_files: false files: | - ${{ steps.meta.outputs.chain }}_runtime.compact.compressed.wasm - srtool-${{ steps.meta.outputs.chain }}.json + ${{ needs.build.outputs.chain }}_runtime.compact.compressed.wasm + srtool-${{ needs.build.outputs.chain }}.json diff --git a/.github/workflows/test-code.yml b/.github/workflows/test-code.yml index 11025f6e1..bafc6bdb8 100644 --- a/.github/workflows/test-code.yml +++ b/.github/workflows/test-code.yml @@ -6,33 +6,31 @@ on: branches: - main +permissions: + contents: read + jobs: test-code: - runs-on: ubuntu-latest + # The bundled RocksDB (librocksdb-sys 0.11) does not build with the GCC of newer images. + runs-on: ubuntu-24.04 env: # Make sure CI fails on all warnings, including Clippy lints RUSTFLAGS: "-Dwarnings" steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 - name: Free up Space and Installation uses: ./.github/actions/shared - name: Install Protoc - uses: arduino/setup-protoc@v1 + uses: arduino/setup-protoc@149f6c87b92550901b26acd1632e11c3662e381f # v1.3.0 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Test - uses: actions-rs/cargo@v1 - with: - command: test - args: --release + run: cargo test --release - name: Test for Runtime Benchmarks - uses: actions-rs/cargo@v1 - with: - command: test - args: --release --features=runtime-benchmarks,try-runtime \ No newline at end of file + run: cargo test --release --features=runtime-benchmarks,try-runtime diff --git a/.github/workflows/version-up.yml b/.github/workflows/version-up.yml index 00a27aa97..1dbf76256 100644 --- a/.github/workflows/version-up.yml +++ b/.github/workflows/version-up.yml @@ -23,13 +23,19 @@ on: type: boolean default: true +permissions: + contents: read + jobs: bump-version: runs-on: ubuntu-latest name: bump version + permissions: + contents: write + pull-requests: write steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 with: fetch-depth: 0 @@ -46,38 +52,47 @@ jobs: - name: Check For Specific Version if: github.event.inputs.specific_version != '' + env: + SPECIFIC_VERSION: ${{ github.event.inputs.specific_version }} + PACKAGES_ALL: ${{ github.event.inputs.packages-all }} run: | - bash .github/scripts/package_version_up.sh ${{ github.event.inputs.specific_version }} - if ${{ github.event.inputs.packages-all }} == 'true'; then - echo "Upgrading crates to ${{ github.event.inputs.specific_version }}" &> changes.txt + bash .github/scripts/package_version_up.sh "$SPECIFIC_VERSION" + if [ "$PACKAGES_ALL" == 'true' ]; then + echo "Upgrading crates to $SPECIFIC_VERSION" &> changes.txt else - echo "Upgrading node to ${{ github.event.inputs.specific_version }}" &> changes.txt + echo "Upgrading node to $SPECIFIC_VERSION" &> changes.txt fi - name: ${{ github.event.inputs.versioning }} Version Up for all if: github.event.inputs.specific_version == '' && github.event.inputs.packages-all == 'true' continue-on-error: false + env: + VERSIONING: ${{ github.event.inputs.versioning }} run: | - cargo set-version --bump ${{ github.event.inputs.versioning }} &> changes.txt + cargo set-version --bump "$VERSIONING" &> changes.txt cat changes.txt - name: ${{ github.event.inputs.versioning }} Version Up for node if: github.event.inputs.specific_version == '' && github.event.inputs.packages-all == 'false' continue-on-error: false + env: + VERSIONING: ${{ github.event.inputs.versioning }} run: | - cargo set-version --bump ${{ github.event.inputs.versioning }} --package pendulum-node &> changes.txt + cargo set-version --bump "$VERSIONING" --package pendulum-node &> changes.txt cat changes.txt - name: "Read file contents" id: read-file - uses: juliangruber/read-file-action@v1 + uses: juliangruber/read-file-action@271ff311a4947af354c6abcd696a306553b9ec18 # v1.1.8 with: path: ./changes.txt - name: Set Chosen Package id: set-pkg + env: + PACKAGES_ALL: ${{ github.event.inputs.packages-all }} run: | - if [ ${{ github.event.inputs.packages-all }} == 'true' ]; then + if [ "$PACKAGES_ALL" == 'true' ]; then echo "name=all" >> "$GITHUB_OUTPUT" else echo "name=node" >> "$GITHUB_OUTPUT" @@ -85,29 +100,36 @@ jobs: - name: Put current date into a variable id: date-now - uses: Kaven-Universe/github-action-current-date-time@v1 + uses: Kaven-Universe/github-action-current-date-time@7c1d8465d1bfd7d35466d2ee82a8e460780561ae # v1.5.0 with: format: "yyyy-MM-dd" - name: Create Release Branch id: new-branch + env: + PKG: ${{ steps.set-pkg.outputs.name }} + DAY: ${{ steps.date-now.outputs.day }} + MONTH: ${{ steps.date-now.outputs.month }} + YEAR: ${{ steps.date-now.outputs.year }} + SPECIFIC_VERSION: ${{ github.event.inputs.specific_version }} + VERSIONING: ${{ github.event.inputs.versioning }} run: | - name=${{ steps.set-pkg.outputs.name }} - now="${{ steps.date-now.outputs.day }}-${{ steps.date-now.outputs.month }}-${{ steps.date-now.outputs.year }}" - - if [ '${{ github.event.inputs.specific_version }}' != '' ]; then - echo "specific version: ${{ github.event.inputs.specific_version }}" - branch_name="release/version-up-to-${{ github.event.inputs.specific_version }}-$name-$now" + name="$PKG" + now="$DAY-$MONTH-$YEAR" + + if [ "$SPECIFIC_VERSION" != '' ]; then + echo "specific version: $SPECIFIC_VERSION" + branch_name="release/version-up-to-$SPECIFIC_VERSION-$name-$now" else - vers=${{ github.event.inputs.versioning }} - echo "versioning: ${{ github.event.inputs.versioning }}" + vers="$VERSIONING" + echo "versioning: $VERSIONING" branch_name="release/$vers-version-up-$name-$now" fi - + echo "name=${branch_name}" >> "$GITHUB_OUTPUT" - - git checkout -b ${branch_name} - git push --set-upstream origin ${branch_name} + + git checkout -b "${branch_name}" + git push --set-upstream origin "${branch_name}" # todo: make this simpler. - name: Commit New Changes to New Branch (all) @@ -117,26 +139,26 @@ jobs: BRANCH: ${{ steps.new-branch.outputs.name }} run: | gh api graphql \ - -F githubRepository=${{ github.repository }} \ - -F branchName=${{ env.BRANCH }} \ - -F expectedHeadOid=$(git rev-parse HEAD) \ + -F githubRepository="$GITHUB_REPOSITORY" \ + -F branchName="$BRANCH" \ + -F expectedHeadOid="$(git rev-parse HEAD)" \ -F commitMessage="$(cat changes.txt)" \ - -F files[][path]="chain-extensions/common/Cargo.toml" -F files[][contents]=$(base64 -w0 chain-extensions/common/Cargo.toml) \ - -F files[][path]="chain-extensions/price/Cargo.toml" -F files[][contents]=$(base64 -w0 chain-extensions/price/Cargo.toml) \ - -F files[][path]="chain-extensions/token/Cargo.toml" -F files[][contents]=$(base64 -w0 chain-extensions/token/Cargo.toml) \ - -F files[][path]="node/Cargo.toml" -F files[][contents]=$(base64 -w0 node/Cargo.toml) \ - -F files[][path]="pallets/orml-currencies-allowance-extension/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/orml-currencies-allowance-extension/Cargo.toml) \ - -F files[][path]="pallets/orml-tokens-management-extension/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/orml-tokens-management-extension/Cargo.toml) \ - -F files[][path]="pallets/parachain-staking/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/parachain-staking/Cargo.toml) \ - -F files[][path]="pallets/parachain-staking/rpc/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/parachain-staking/rpc/Cargo.toml) \ - -F files[][path]="pallets/parachain-staking/rpc/runtime-api/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/parachain-staking/rpc/runtime-api/Cargo.toml) \ - -F files[][path]="pallets/treasury-buyout-extension/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/treasury-buyout-extension/Cargo.toml) \ - -F files[][path]="pallets/vesting-manager/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/vesting-manager/Cargo.toml) \ - -F files[][path]="runtime/amplitude/Cargo.toml" -F files[][contents]=$(base64 -w0 runtime/amplitude/Cargo.toml) \ - -F files[][path]="runtime/common/Cargo.toml" -F files[][contents]=$(base64 -w0 runtime/common/Cargo.toml) \ - -F files[][path]="runtime/foucoco/Cargo.toml" -F files[][contents]=$(base64 -w0 runtime/foucoco/Cargo.toml) \ - -F files[][path]="runtime/integration-tests/Cargo.toml" -F files[][contents]=$(base64 -w0 runtime/integration-tests/Cargo.toml) \ - -F files[][path]="runtime/pendulum/Cargo.toml" -F files[][contents]=$(base64 -w0 runtime/pendulum/Cargo.toml) \ + -F "files[][path]=chain-extensions/common/Cargo.toml" -F "files[][contents]=$(base64 -w0 chain-extensions/common/Cargo.toml)" \ + -F "files[][path]=chain-extensions/price/Cargo.toml" -F "files[][contents]=$(base64 -w0 chain-extensions/price/Cargo.toml)" \ + -F "files[][path]=chain-extensions/token/Cargo.toml" -F "files[][contents]=$(base64 -w0 chain-extensions/token/Cargo.toml)" \ + -F "files[][path]=node/Cargo.toml" -F "files[][contents]=$(base64 -w0 node/Cargo.toml)" \ + -F "files[][path]=pallets/orml-currencies-allowance-extension/Cargo.toml" -F "files[][contents]=$(base64 -w0 pallets/orml-currencies-allowance-extension/Cargo.toml)" \ + -F "files[][path]=pallets/orml-tokens-management-extension/Cargo.toml" -F "files[][contents]=$(base64 -w0 pallets/orml-tokens-management-extension/Cargo.toml)" \ + -F "files[][path]=pallets/parachain-staking/Cargo.toml" -F "files[][contents]=$(base64 -w0 pallets/parachain-staking/Cargo.toml)" \ + -F "files[][path]=pallets/parachain-staking/rpc/Cargo.toml" -F "files[][contents]=$(base64 -w0 pallets/parachain-staking/rpc/Cargo.toml)" \ + -F "files[][path]=pallets/parachain-staking/rpc/runtime-api/Cargo.toml" -F "files[][contents]=$(base64 -w0 pallets/parachain-staking/rpc/runtime-api/Cargo.toml)" \ + -F "files[][path]=pallets/treasury-buyout-extension/Cargo.toml" -F "files[][contents]=$(base64 -w0 pallets/treasury-buyout-extension/Cargo.toml)" \ + -F "files[][path]=pallets/vesting-manager/Cargo.toml" -F "files[][contents]=$(base64 -w0 pallets/vesting-manager/Cargo.toml)" \ + -F "files[][path]=runtime/amplitude/Cargo.toml" -F "files[][contents]=$(base64 -w0 runtime/amplitude/Cargo.toml)" \ + -F "files[][path]=runtime/common/Cargo.toml" -F "files[][contents]=$(base64 -w0 runtime/common/Cargo.toml)" \ + -F "files[][path]=runtime/foucoco/Cargo.toml" -F "files[][contents]=$(base64 -w0 runtime/foucoco/Cargo.toml)" \ + -F "files[][path]=runtime/integration-tests/Cargo.toml" -F "files[][contents]=$(base64 -w0 runtime/integration-tests/Cargo.toml)" \ + -F "files[][path]=runtime/pendulum/Cargo.toml" -F "files[][contents]=$(base64 -w0 runtime/pendulum/Cargo.toml)" \ -F 'query=@.github/api/createCommitOnBranch.gql' - name: Commit New Changes to New Branch (node) @@ -146,25 +168,29 @@ jobs: BRANCH: ${{ steps.new-branch.outputs.name }} run: | gh api graphql \ - -F githubRepository=${{ github.repository }} \ - -F branchName=${{ env.BRANCH }} \ - -F expectedHeadOid=$(git rev-parse HEAD) \ + -F githubRepository="$GITHUB_REPOSITORY" \ + -F branchName="$BRANCH" \ + -F expectedHeadOid="$(git rev-parse HEAD)" \ -F commitMessage="$(cat changes.txt)" \ - -F files[][path]="node/Cargo.toml" -F files[][contents]=$(base64 -w0 node/Cargo.toml) \ + -F "files[][path]=node/Cargo.toml" -F "files[][contents]=$(base64 -w0 node/Cargo.toml)" \ -F 'query=@.github/api/createCommitOnBranch.gql' - name: Prepare Pull Request title id: pr-title + env: + SPECIFIC_VERSION: ${{ github.event.inputs.specific_version }} + PKG: ${{ steps.set-pkg.outputs.name }} + VERSIONING: ${{ github.event.inputs.versioning }} run: | - if ${{ github.event.inputs.specific_version }} == ''; then - echo "title=release: Bump ${{ steps.set-pkg.outputs.name }} crate version/s to ${{ github.event.inputs.versioning }}" >> "$GITHUB_OUTPUT" + if [ "$SPECIFIC_VERSION" == '' ]; then + echo "title=release: Bump $PKG crate version/s to $VERSIONING" >> "$GITHUB_OUTPUT" else vers=$( cargo metadata --format-version=1 --no-deps | jq '.packages[] | select(.name == "pendulum-node") | .version' | tr -d '"' ) - echo "title=release: Force bump ${{ steps.set-pkg.outputs.name }} version/s to $vers" >> "$GITHUB_OUTPUT" + echo "title=release: Force bump $PKG version/s to $vers" >> "$GITHUB_OUTPUT" fi - name: Create Pull Request - uses: thomaseizinger/create-pull-request@master + uses: thomaseizinger/create-pull-request@84104598ab3d603b60080ddfabd783999765a992 # master with: github_token: ${{ secrets.GITHUB_TOKEN }} title: ${{ steps.pr-title.outputs.title }}