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 157392b9..6d69acd0 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 @@ -106,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 }} @@ -114,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 @@ -129,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 @@ -146,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 @@ -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: @@ -288,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: @@ -316,18 +345,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.1.0 + 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 }}"}'