diff --git a/.github/actions/get_dfx_version/action.yml b/.github/actions/get_dfx_version/action.yml deleted file mode 100644 index 3797571230..0000000000 --- a/.github/actions/get_dfx_version/action.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Get dfx version -description: Determines Azle's dfx version -outputs: - dfx-version: - description: Returns the version of dfx that Azle will test against and use to generate its Wasm binary templates - value: ${{ steps.get-dfx-version.outputs.dfx-version }} -runs: - using: composite - steps: - - id: get-dfx-version - run: | - DFX_VERSION=$(jq -r '.azle.globalDependencies.dfx // error("dfx version not found")' "package.json") - echo "dfx-version=${DFX_VERSION}" >> "$GITHUB_OUTPUT" - shell: bash diff --git a/.github/actions/get_dfx_version/README.md b/.github/actions/setup_dfx/README.md similarity index 84% rename from .github/actions/get_dfx_version/README.md rename to .github/actions/setup_dfx/README.md index 6a114e88db..293d76f9e3 100644 --- a/.github/actions/get_dfx_version/README.md +++ b/.github/actions/setup_dfx/README.md @@ -17,8 +17,8 @@ checking out a specific branch. steps: - uses: actions/checkout@v4 - - id: get-dfx-version - uses: ./.github/actions/get_dfx_version + - id: setup-dfx + uses: ./.github/actions/setup_dfx - - run: echo ${{ steps.get-dfx-version.outputs.dfx-version }} + - run: echo ${{ steps.setup-dfx.outputs.dfx-version }} ``` diff --git a/.github/actions/setup_dfx/action.yml b/.github/actions/setup_dfx/action.yml new file mode 100644 index 0000000000..1d2103cd1a --- /dev/null +++ b/.github/actions/setup_dfx/action.yml @@ -0,0 +1,27 @@ +name: Setup dfx +description: 'Sets up dfx by detecting version from package.json and installing it. (Note: DFX must be installed before `npm install` because the azle installation process requires dfx)' +inputs: + dfx-version: + description: 'The version of dfx to install (optional - will read from package.json if not provided)' + required: false +outputs: + dfx-version: + description: 'The version of dfx that was installed' + value: ${{ steps.get-dfx-version.outputs.dfx-version }} +runs: + using: composite + steps: + - id: get-dfx-version + if: inputs.dfx-version == '' + run: | + DFX_VERSION=$(jq -r '.azle.globalDependencies.dfx // error("dfx version not found")' "package.json") + echo "dfx-version=${DFX_VERSION}" >> "$GITHUB_OUTPUT" + shell: bash + + - name: Install dfx + run: | + VERSION="${{ inputs.dfx-version || steps.get-dfx-version.outputs.dfx-version }}" + # Install dfx (Note: dfx must be installed before `npx azle` because the azle installation process requires dfx) + src/build/stable/commands/install_global_dependencies/install_dfx.sh $VERSION + echo "$HOME/.local/share/dfx/bin" >> $GITHUB_PATH + shell: bash diff --git a/.github/scripts/publish_github_action.sh b/.github/scripts/publish_github_action.sh index df959b3edf..7d326a5bc4 100755 --- a/.github/scripts/publish_github_action.sh +++ b/.github/scripts/publish_github_action.sh @@ -26,34 +26,34 @@ else npm publish fi -# TODO loop through checking for the status instead of sleeping -echo -e "sleeping for 30 seconds to ensure azle@$VERSION is fully registered on npm" +# # TODO loop through checking for the status instead of sleeping +# echo -e "sleeping for 30 seconds to ensure azle@$VERSION is fully registered on npm" -sleep 30 +# sleep 30 -for directory in ${directories[@]} -do - cd "$directory" - echo "updating $directory" +# for directory in ${directories[@]} +# do +# cd "$directory" +# echo "updating $directory" - sed -E -i "s/(\"azle\": \")(.*)(\")/\1$VERSION\3/" package.json - npm install +# sed -E -i "s/(\"azle\": \")(.*)(\")/\1$VERSION\3/" package.json +# npm install - rm -rf node_modules +# rm -rf node_modules - cd $root_dir -done +# cd $root_dir +# done -git add --all -git commit -am "azle-bot automated release $VERSION" -git push origin $GITHUB_HEAD_REF +# git add --all +# git commit -am "azle-bot automated release $VERSION" +# git push origin $GITHUB_HEAD_REF -git tag $VERSION -git push origin $VERSION +# git tag $VERSION +# git push origin $VERSION -if [[ "$VERSION" == *"-rc."* ]]; -then - gh release create "$VERSION" -t "$VERSION" --prerelease -else - gh release create "$VERSION" -t "$VERSION" -fi +# if [[ "$VERSION" == *"-rc."* ]]; +# then +# gh release create "$VERSION" -t "$VERSION" --prerelease +# else +# gh release create "$VERSION" -t "$VERSION" +# fi diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fc7bbe141b..2d61ac8886 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,58 +43,14 @@ jobs: name: Deploy release # Only run this job if it's a release branch. This job will run instead of run-tests and will automatically publish another commit which will be tested if: ${{ needs.determine-should-release.outputs.should-release == 'true' }} + needs: - determine-should-release - get-test-infos - runs-on: ubuntu-latest - env: + + uses: ./.github/workflows/release_parallel.yml + secrets: GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} # All commits must be verified GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.ref || github.ref }} - token: ${{ secrets.LASTMJS_GITHUB_TOKEN || github.token }} - - - id: get-node-version - uses: ./.github/actions/get_node_version - - - uses: actions/setup-node@v4 - with: - node-version: ${{ steps.get-node-version.outputs.node-version }} - registry-url: https://registry.npmjs.org - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - - name: Install curl - run: sudo apt-get install curl -y - - - id: get-dfx-version - uses: ./.github/actions/get_dfx_version - - - name: Install dfx - run: | - # Install dfx (Note: dfx must be installed before `npx azle` because the azle installation process requires dfx) - src/build/stable/commands/install_global_dependencies/install_dfx.sh ${{ steps.get-dfx-version.outputs.dfx-version }} - echo "$HOME/.local/share/dfx/bin" >> $GITHUB_PATH - - - run: npm install - - - name: Install global dependencies - run: | - AZLE_VERBOSE=true npx azle install-global-dependencies --rust --wasi2ic - - # TODO we should use some Action-specific bot account - - name: Configure git for publishing release - run: | - git config --global user.name 'Jordan Last' - git config --global user.email 'jordan.michael.last@gmail.com' - git config --global commit.gpgsign true - echo -n "$GPG_SIGNING_KEY" | base64 --decode | gpg --import - git config --global user.signingkey C8B77BCBE16CD2B94B43F9C8757397B82D4ED7B0 - - - name: Publish release - run: | - BRANCH_NAME="${{ github.head_ref }}" - RELEASE_VERSION="${BRANCH_NAME:9}" - ./.github/scripts/publish_github_action.sh $RELEASE_VERSION ${{ toJSON(needs.get-test-infos.outputs.test-infos) }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + LASTMJS_GITHUB_TOKEN: ${{ secrets.LASTMJS_GITHUB_TOKEN }} diff --git a/.github/workflows/release_parallel.yml b/.github/workflows/release_parallel.yml new file mode 100644 index 0000000000..fc026b8a59 --- /dev/null +++ b/.github/workflows/release_parallel.yml @@ -0,0 +1,208 @@ +name: Parallel Release +on: + workflow_call: + secrets: + GPG_SIGNING_KEY: + required: true + GH_TOKEN: + required: true + NPM_TOKEN: + required: true + LASTMJS_GITHUB_TOKEN: + required: true + +jobs: + prepare-release: + name: Prepare Release + runs-on: ubuntu-latest + env: + GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} # All commits must be verified + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + outputs: + release-version: ${{ steps.get-version.outputs.release-version }} + test-infos: ${{ steps.get-test-infos.outputs.test-infos }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.ref || github.ref }} + token: ${{ secrets.LASTMJS_GITHUB_TOKEN || github.token }} + + - id: get-version + run: | + BRANCH_NAME="${{ github.event.pull_request.head.ref || github.ref_name }}" + RELEASE_VERSION="${BRANCH_NAME:9}" + echo "release-version=$RELEASE_VERSION" >> $GITHUB_OUTPUT + + - id: get-node-version + uses: ./.github/actions/get_node_version + + - uses: actions/setup-node@v4 + with: + node-version: ${{ steps.get-node-version.outputs.node-version }} + registry-url: https://registry.npmjs.org + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Install curl + run: sudo apt-get install curl -y + + - name: Setup dfx + uses: ./.github/actions/setup_dfx + + - run: npm install + + - name: Install global dependencies + run: | + AZLE_VERBOSE=true npx azle install-global-dependencies --rust --wasi2ic + + # TODO we should use some Action-specific bot account + - name: Configure git for publishing release + run: | + git config --global user.name 'Jordan Last' + git config --global user.email 'jordan.michael.last@gmail.com' + git config --global commit.gpgsign true + echo -n "$GPG_SIGNING_KEY" | base64 --decode | gpg --import + git config --global user.signingkey C8B77BCBE16CD2B94B43F9C8757397B82D4ED7B0 + + - name: Update version and build templates + run: | + VERSION=${{ steps.get-version.outputs.release-version }} + sed -E -i "s/(\"version\": \")(.*)(\")/\1$VERSION\3/" package.json + sed -E -i "s/(\"version\": \")(.*)(\")/\1$VERSION\3/" dfx_extension/extension.json + npm install + ## TODO bring these back after we are done testing + # AZLE_VERBOSE=true npx azle template + # AZLE_VERBOSE=true npx azle template --experimental + + - name: Publish to npm + run: | + if [[ "${{ steps.get-version.outputs.release-version }}" == *"-rc."* ]]; then + npm publish --tag next + else + npm publish + fi + + - id: get-test-infos + uses: ./.github/actions/get_test_infos + with: + directories: | + ./examples + ./tests + + update-test-files-for-release-commit: + needs: prepare-release + name: Update ${{ matrix.test.name }} + runs-on: ubuntu-latest + env: + GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + strategy: + fail-fast: false + matrix: + test: ${{ fromJson(needs.prepare-release.outputs.test-infos) }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.ref || github.ref }} + token: ${{ secrets.LASTMJS_GITHUB_TOKEN || github.token }} + + - id: get-node-version + uses: ./.github/actions/get_node_version + + - uses: actions/setup-node@v4 + with: + node-version: ${{ steps.get-node-version.outputs.node-version }} + + - name: Setup dfx + uses: ./.github/actions/setup_dfx + + - name: Update azle version + run: | + npm install + cd ${{ matrix.test.path }} + sed -E -i "s/(\"azle\": \")(.*)(\")/\1${{ needs.prepare-release.outputs.release-version }}\3/" package.json + npm install + + - name: Run npm test (continue on error) + working-directory: ${{ matrix.test.path }} + continue-on-error: true + run: npm test + + # TODO we should use some Action-specific bot account + - name: Commit and push changes + run: | + git config --global user.name 'Jordan Last' + git config --global user.email 'jordan.michael.last@gmail.com' + git config --global commit.gpgsign true + echo -n "$GPG_SIGNING_KEY" | base64 --decode | gpg --import + git config --global user.signingkey C8B77BCBE16CD2B94B43F9C8757397B82D4ED7B0 + BRANCH_NAME="update-${{ needs.prepare-release.outputs.release-version }}-$(echo '${{ matrix.test.displayPath }}' | sed 's/\//-/g')" + git switch -c "$BRANCH_NAME" + git add --all + if ! git diff --cached --quiet; then + git commit -m "Update dependencies for ${{ matrix.test.displayPath }}" + else + echo "No changes to commit. Skipping commit and push." + fi + git push origin "$BRANCH_NAME" + + finalize-release: + needs: [prepare-release, update-test-files-for-release-commit] + name: Finalize Release + runs-on: ubuntu-latest + env: + GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.ref || github.ref }} + token: ${{ secrets.LASTMJS_GITHUB_TOKEN }} + + - name: Cherry-pick and squash changes + env: + PAT: ${{ secrets.LASTMJS_GITHUB_TOKEN }} + run: | + git config --global user.name 'Jordan Last' + git config --global user.email 'jordan.michael.last@gmail.com' + git config --global commit.gpgsign true + echo -n "$GPG_SIGNING_KEY" | base64 --decode | gpg --import + git config --global user.signingkey C8B77BCBE16CD2B94B43F9C8757397B82D4ED7B0 + + CURRENT_BRANCH=$(git branch --show-current) + BASE_COMMIT=$(git rev-parse HEAD) + + git fetch --all + # Get all update branches and cherry-pick their changes + for branch in $(git branch -r | grep "origin/update-${{ needs.prepare-release.outputs.release-version }}-" | sed 's/origin\///'); do + echo "Cherry-picking changes from branch: $branch" + git fetch origin $branch:$branch + + git merge --squash "$branch" || { + echo "Failed to merge $branch" + git merge --abort + exit 1 + } + git commit -m "Squashed changes from $branch" || true + + # Delete the remote branch + git push origin --delete "$branch" + done + + # Squash all cherry-picked commits into one + git reset --soft $BASE_COMMIT + git commit -am "Update all dependencies for release ${{ needs.prepare-release.outputs.release-version }}" + + git push origin HEAD:$CURRENT_BRANCH + + - name: Create release + run: | + VERSION=${{ needs.prepare-release.outputs.release-version }} + git tag $VERSION + git push origin $VERSION + + if [[ "$VERSION" == *"-rc."* ]]; then + gh release create "$VERSION" -t "$VERSION" --prerelease + else + gh release create "$VERSION" -t "$VERSION" + fi diff --git a/.github/workflows/run_test.yml b/.github/workflows/run_test.yml index 49f8e74415..439d642b6c 100644 --- a/.github/workflows/run_test.yml +++ b/.github/workflows/run_test.yml @@ -30,7 +30,7 @@ jobs: # os: [macos-latest, ubuntu-latest] os: [ubuntu-latest] azle_source: - - ${{ inputs.include_npm == 'true' && 'npm' || 'repo' }} + - ${{ inputs.include_npm == true && 'npm' || 'repo' }} tests: ${{ fromJSON(inputs.test_infos) }} steps: - uses: actions/checkout@v4 @@ -65,16 +65,11 @@ jobs: with: node-version: ${{ steps.get-node-version.outputs.node-version }} - - id: get-dfx-version - uses: ./.github/actions/get_dfx_version + - id: setup-dfx + uses: ./.github/actions/setup_dfx - name: Run pre-test Azle setup run: | - - # Install dfx (Note: DFX must be installed before `npm install` because the azle installation process requires dfx) - src/build/stable/commands/install_global_dependencies/install_dfx.sh ${{ steps.get-dfx-version.outputs.dfx-version }} - echo "$HOME/.local/share/dfx/bin" >> $GITHUB_PATH - # MacOS-specific DNS configuration if [[ "${{ matrix.os }}" == "macos-latest" ]]; then sudo networksetup -setdnsservers Ethernet 9.9.9.9 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 61bb09a8be..9f8c43d106 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,7 +9,7 @@ on: push: branches: - main - pull_request: # Runs on pull requests to any branch + pull_request: jobs: determine-should-run-tests: diff --git a/dfx_extension/extension.json b/dfx_extension/extension.json index 88e7a5fbe6..957cc03f00 100644 --- a/dfx_extension/extension.json +++ b/dfx_extension/extension.json @@ -1,6 +1,6 @@ { "name": "azle", - "version": "0.24.1", + "version": "0.24.2-rc.58", "homepage": "https://github.com/dfinity/dfx-extensions", "authors": "", "summary": "", diff --git a/package-lock.json b/package-lock.json index de86c9c76d..079c1c5eff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "azle", - "version": "0.25.0", + "version": "0.24.2-rc.58", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "azle", - "version": "0.25.0", + "version": "0.24.2-rc.58", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index c7675cedef..0895f70c29 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "azle", - "version": "0.25.0", + "version": "0.24.2-rc.58", "description": "TypeScript and JavaScript CDK for the Internet Computer", "scripts": { "typecheck": "tsc --noEmit",