From f662d521b29d2f6c2f9a87636f0d761749773695 Mon Sep 17 00:00:00 2001 From: Zachary Brown Date: Thu, 19 Dec 2024 13:46:33 -0800 Subject: [PATCH 1/6] ci: release action version fix --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 157392b9..38fca30d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -318,7 +318,7 @@ jobs: zip -r cadt-linux-x64-${{ steps.tag-name.outputs.TAGNAME }}.zip cadt-linux-x64 - name: Release - uses: softprops/action-gh-release@v2.1.0 + uses: softprops/action-gh-release@v2 with: files: | cadt-windows-x64-${{ steps.tag-name.outputs.TAGNAME }}.zip From 7eefdbc0a858683ef8eb471dbb5186f8019f749e Mon Sep 17 00:00:00 2001 From: Zachary Brown Date: Thu, 19 Dec 2024 13:56:28 -0800 Subject: [PATCH 2/6] ci: use ARM runners instead of qemu --- .github/workflows/build.yaml | 111 +++++++++++++++++++++-------------- 1 file changed, 67 insertions(+), 44 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 38fca30d..f433fd0a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -27,6 +27,10 @@ jobs: artifact-name: cadt-linux-x64 build-command: npm run create-linux-x64-dist sqlite-path: ./node_modules/sqlite3/build/Release/ + - runs-on: [Linux, ARM64] + artifact-name: cadt-linux-arm64 + build-command: npm run create-linux-arm64-dist + sqlite-path: ./node_modules/sqlite3/build/Release/ - runs-on: macos-latest artifact-name: cadt-macos-x64 build-command: npm run create-mac-x64-dist @@ -37,9 +41,6 @@ jobs: sqlite-path: .\node_modules\sqlite3\build\Release\ steps: - - name: Clean workspace - uses: Chia-Network/actions/clean-workspace@main - - name: Checkout Code uses: actions/checkout@v4 @@ -55,6 +56,28 @@ jobs: run: npm pkg delete scripts.prepare if: matrix.runs-on != 'windows-2019' + # RC release should not be set as latest + - name: Decide if release should be set as latest + id: is_latest + shell: bash + run: | + unset IS_LATEST + + echo "Github ref is $GITHUB_REF" + + if [[ "$GITHUB_REF" =~ "-rc" ]]; then + echo "release candidate tag matched" + IS_LATEST='false' + IS_PRERELEASE='true' + else + echo "main branch release matched" + IS_LATEST='true' + IS_PRERELEASE='false' + fi + + echo "IS_LATEST=${IS_LATEST}" >> "$GITHUB_OUTPUT" + echo "IS_PRERELEASE=${IS_PRERELEASE}" >> "$GITHUB_OUTPUT" + - name: npm install run: | node --version @@ -177,53 +200,53 @@ jobs: name: ${{ matrix.artifact-name }} path: ${{ github.workspace }}/dist - build-linux-arm64: - name: Build Linux ARM64 Binaries - runs-on: ubuntu-latest - steps: - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: arm64 - - - uses: Chia-Network/actions/clean-workspace@main - - - name: Checkout Code - uses: actions/checkout@v4 - - - name: Determine npm cache key - id: npm-cache - run: | - CACHE_KEY=node-linux-arm64-$(shasum package.json | awk '{ print $1 }')-$(shasum package-lock.json | awk '{ print $1 }') - echo "CACHE_KEY=$CACHE_KEY" >> $GITHUB_OUTPUT - - - name: Setup NPM Cache - uses: actions/cache@v4 - with: - path: node_modules - key: ${{ steps.npm-cache.outputs.CACHE_KEY }} - - - name: Build arm 64 dist - run: | - mkdir pkgcache - docker run --rm --platform linux/arm64 -v $(pwd):/app -w /app -e PKG_CACHE_PATH=pkgcache node:20.16 /bin/bash -c "npm pkg delete scripts.prepare && npm install && npm i -g @babel/cli @babel/preset-env pkg && npm run create-linux-arm64-dist" - - - name: Copy sqlite3 - run: | - sudo cp ./node_modules/sqlite3/build/Release/node_sqlite3.node ./dist/ - - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: cadt-linux-arm64 - path: ${{ github.workspace }}/dist + # build-linux-arm64: + # name: Build Linux ARM64 Binaries + # runs-on: ubuntu-latest + # steps: + # - name: Set up QEMU + # uses: docker/setup-qemu-action@v3 + # with: + # platforms: arm64 + + # - uses: Chia-Network/actions/clean-workspace@main + + # - name: Checkout Code + # uses: actions/checkout@v4 + + # - name: Determine npm cache key + # id: npm-cache + # run: | + # CACHE_KEY=node-linux-arm64-$(shasum package.json | awk '{ print $1 }')-$(shasum package-lock.json | awk '{ print $1 }') + # echo "CACHE_KEY=$CACHE_KEY" >> $GITHUB_OUTPUT + + # - name: Setup NPM Cache + # uses: actions/cache@v4 + # with: + # path: node_modules + # key: ${{ steps.npm-cache.outputs.CACHE_KEY }} + + # - name: Build arm 64 dist + # run: | + # mkdir pkgcache + # docker run --rm --platform linux/arm64 -v $(pwd):/app -w /app -e PKG_CACHE_PATH=pkgcache node:20.16 /bin/bash -c "npm pkg delete scripts.prepare && npm install && npm i -g @babel/cli @babel/preset-env pkg && npm run create-linux-arm64-dist" + + # - name: Copy sqlite3 + # run: | + # sudo cp ./node_modules/sqlite3/build/Release/node_sqlite3.node ./dist/ + + # - name: Upload artifacts + # uses: actions/upload-artifact@v4 + # with: + # name: cadt-linux-arm64 + # path: ${{ github.workspace }}/dist debs: name: Build ${{ matrix.name }} deb runs-on: ubuntu-latest needs: - build - - build-linux-arm64 + # - build-linux-arm64 strategy: matrix: include: From 0fb9e07e4477fa75752d3e6bde812534feb79898 Mon Sep 17 00:00:00 2001 From: Zachary Brown Date: Thu, 19 Dec 2024 14:10:56 -0800 Subject: [PATCH 3/6] ci: rc release logic --- .github/workflows/auto-release-rc.yml | 79 +++++++++++++++++++++++++++ .github/workflows/build.yaml | 35 ++++++++++-- 2 files changed, 110 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/auto-release-rc.yml diff --git a/.github/workflows/auto-release-rc.yml b/.github/workflows/auto-release-rc.yml new file mode 100644 index 00000000..274659b4 --- /dev/null +++ b/.github/workflows/auto-release-rc.yml @@ -0,0 +1,79 @@ +# Compares the version in package.json to tags on the repo. If the tag doesn't exist, a new tag is created, which +# then triggers the normal "on tag" release automation in the build job +name: Auto Tag RC + +on: + push: + branches: + - develop + +concurrency: + group: rc-release-check + +jobs: + release-dev: + name: Release rc version + runs-on: ubuntu-latest + steps: + - name: Checkout current branch + uses: actions/checkout@v4 + with: + # Need REPO_COMMIT token so when the tag is created, the tag automation runs + token: ${{ secrets.REPO_COMMIT }} + fetch-depth: 0 + + - name: Setup commit signing for ChiaAutomation + uses: Chia-Network/actions/commit-sign/gpg@main + with: + gpg_private_key: ${{ secrets.CHIA_AUTOMATION_PRIVATE_GPG_KEY }} + passphrase: ${{ secrets.CHIA_AUTOMATION_PRIVATE_GPG_PASSPHRASE }} + + - name: Check for current version tag. Create if it doesn't exist + env: + GH_TOKEN: ${{ github.token }} + run: | + stable_version=$(gh release list --limit 1 --order desc --exclude-pre-releases --json tagName --jq ".[].tagName") + echo "Latest release is $stable_version" + rc_version=$(gh release list --json tagName --jq ".[] | select(.tagName | test(\"${version}-rc*\")) | .tagName") + echo "Latest release candidate is $rc_version" + + if [[ -z ${rc_version} ]]; then + # Extract the major, minor, and patch versions + IFS='.' read -r major minor patch <<< "$stable_version" + + # Increment the patch version + new_patch=$((patch + 1)) + + # Construct the new version string + version="$major.$minor.$new_patch-rc1" + + echo "New version: $version" + + else + # Extract the major, minor, patch, and rc parts + IFS='.-' read -r major minor patch rc <<< "$rc_version" + + # Extract just the number of the rc + rc_number="${rc#rc}" + + # Increment the rc number + rc_number=$((rc_number +1)) + + # Construct the new version string + version="$major.$minor.$patch-rc$rc_number" + + echo "New version: $version" + + fi + + if [ $(git tag -l "$version") ]; then + echo "$version tag exists, deleting..." + git tag -d $version + git push --delete origin $version + fi + echo "Tag does not exist. Creating and pushing tag" + rm -f CHANGELOG.md + npx conventional-changelog-cli -p angular -i CHANGELOG.md -s -r 0 + changes=$(npx conventional-changelog-cli -r 1 | tail -n +2) + git tag $version -m "Release $version $changes" + git push origin $version diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f433fd0a..1988d932 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -129,7 +129,7 @@ jobs: # Mac .pkg build + sign - name: Import Apple installer signing certificate - if: matrix.runs-on == 'macos-latest' && steps.check_secrets.outputs.HAS_SIGNING_SECRET + if: matrix.runs-on == 'macos-latest' && steps.check_secrets.outputs.HAS_SIGNING_SECRET && contains( github.ref, '-rc') uses: Apple-Actions/import-codesign-certs@v3 with: keychain-password: ${{ secrets.KEYCHAIN_PASSWORD }} @@ -137,7 +137,7 @@ jobs: p12-password: ${{ secrets.APPLE_DEV_ID_INSTALLER_PASS }} - name: Import Apple Application signing certificate - if: matrix.runs-on == 'macos-latest' && steps.check_secrets.outputs.HAS_SIGNING_SECRET + if: matrix.runs-on == 'macos-latest' && steps.check_secrets.outputs.HAS_SIGNING_SECRET && contains( github.ref, '-rc') uses: Apple-Actions/import-codesign-certs@v3 with: create-keychain: false # Created when importing the first cert @@ -152,7 +152,7 @@ jobs: cp -r ${{ github.workspace }}/dist ${{ github.workspace }}/build-scripts/macos/application - name: Sign Mac binaries - if: matrix.runs-on == 'macos-latest' && steps.check_secrets.outputs.HAS_SIGNING_SECRET + if: matrix.runs-on == 'macos-latest' && steps.check_secrets.outputs.HAS_SIGNING_SECRET && contains( github.ref, '-rc') run: | echo "Signing the binaries" codesign -f -s "Developer ID Application: Chia Network Inc." --timestamp --options=runtime --entitlements ${{ github.workspace }}/build-scripts/macos/entitlements.mac.plist ${{ github.workspace }}/build-scripts/macos/application/cadt @@ -169,7 +169,7 @@ jobs: cp ${{ github.workspace }}/build-scripts/macos/target/pkg/CADT-macos-installer-x64.pkg ${{ github.workspace }}/build-scripts/macos/target/ready-to-upload/CADT-macos-installer-x64.pkg - name: Notarize Mac .pkg - if: matrix.runs-on == 'macos-latest' && steps.check_secrets.outputs.HAS_SIGNING_SECRET + if: matrix.runs-on == 'macos-latest' && steps.check_secrets.outputs.HAS_SIGNING_SECRET && contains( github.ref, '-rc') run: | mkdir -p ${{ github.workspace }}/build-scripts/macos/target/pkg-signed @@ -339,18 +339,45 @@ jobs: zip -r cadt-windows-x64-${{ steps.tag-name.outputs.TAGNAME }}.zip cadt-windows-x64 zip -r cadt-macos-x64-${{ steps.tag-name.outputs.TAGNAME }}.zip cadt-mac-installer zip -r cadt-linux-x64-${{ steps.tag-name.outputs.TAGNAME }}.zip cadt-linux-x64 + zip -r cadt-linux-arm64-${{ steps.tag-name.outputs.TAGNAME }}.zip cadt-linux-arm64 + + # RC release should not be set as latest + - name: Decide if release should be set as latest + id: is_latest + shell: bash + run: | + unset IS_LATEST + + echo "Github ref is $GITHUB_REF" + + if [[ "$GITHUB_REF" =~ "-rc" ]]; then + echo "release candidate tag matched" + IS_LATEST='false' + IS_PRERELEASE='true' + else + echo "main branch release matched" + IS_LATEST='true' + IS_PRERELEASE='false' + fi + + echo "IS_LATEST=${IS_LATEST}" >> "$GITHUB_OUTPUT" + echo "IS_PRERELEASE=${IS_PRERELEASE}" >> "$GITHUB_OUTPUT" - name: Release uses: softprops/action-gh-release@v2 with: + prerelease: ${{steps.is_latest.outputs.IS_PRERELEASE}} + make_latest: "${{steps.is_latest.outputs.IS_LATEST}}" files: | cadt-windows-x64-${{ steps.tag-name.outputs.TAGNAME }}.zip cadt-macos-x64-${{ steps.tag-name.outputs.TAGNAME }}.zip cadt-linux-x64-${{ steps.tag-name.outputs.TAGNAME }}.zip + cadt-linux-arm64-${{ steps.tag-name.outputs.TAGNAME }}.zip cadt-linux-x64-deb/*.deb cadt-linux-arm64-deb/*.deb - name: Trigger apt repo update + if: startsWith(github.ref, 'refs/tags/') && !contains( github.ref, '-rc') uses: Chia-Network/actions/github/glue@main with: json_data: '{"cadt_repo":"cadt","release_version":"${{ steps.tag-name.outputs.TAGNAME }}"}' From f7b179be3250fa863d01e6bbc474d6f9a434985b Mon Sep 17 00:00:00 2001 From: Zachary Brown Date: Thu, 19 Dec 2024 14:14:30 -0800 Subject: [PATCH 4/6] ci: rc release logic --- .github/workflows/auto-release-rc.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/auto-release-rc.yml b/.github/workflows/auto-release-rc.yml index 274659b4..f0d3df12 100644 --- a/.github/workflows/auto-release-rc.yml +++ b/.github/workflows/auto-release-rc.yml @@ -6,6 +6,7 @@ on: push: branches: - develop + - rc concurrency: group: rc-release-check From ed43c4af1e8b3566e2fafc9ac90eafa61581302f Mon Sep 17 00:00:00 2001 From: Zachary Brown Date: Thu, 19 Dec 2024 14:21:29 -0800 Subject: [PATCH 5/6] ci: rc release logic --- .github/workflows/build.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1988d932..6d69acd0 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -311,12 +311,18 @@ jobs: name: cadt-mac-installer path: cadt-mac-installer - - name: Download Linux artifacts + - name: Download x64 Linux artifacts uses: actions/download-artifact@v4 with: name: cadt-linux-x64 path: cadt-linux-x64 + - name: Download arm64 Linux artifacts + uses: actions/download-artifact@v4 + with: + name: cadt-linux-arm64 + path: cadt-linux-arm64 + - name: Download Linux x64 deb uses: actions/download-artifact@v4 with: From 42048e9decb577b47c84ed22f129c5186c1b3a5f Mon Sep 17 00:00:00 2001 From: Zachary Brown Date: Thu, 19 Dec 2024 14:47:44 -0800 Subject: [PATCH 6/6] ci: rc release logic --- .github/workflows/auto-release-rc.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/auto-release-rc.yml b/.github/workflows/auto-release-rc.yml index f0d3df12..274659b4 100644 --- a/.github/workflows/auto-release-rc.yml +++ b/.github/workflows/auto-release-rc.yml @@ -6,7 +6,6 @@ on: push: branches: - develop - - rc concurrency: group: rc-release-check