From e53af6d38bfe82ed0b77b5f01ac144ea784bf25e Mon Sep 17 00:00:00 2001 From: Aaron Leopold <36278431+aaronleopold@users.noreply.github.com> Date: Tue, 6 Feb 2024 21:30:32 -0700 Subject: [PATCH 1/8] Add logic to scratch version script --- Cargo.lock | 6 +++--- crates/cli/Cargo.toml | 2 +- crates/integrations/Cargo.toml | 2 +- crates/prisma-cli/Cargo.toml | 2 +- scripts/release/bump-version.sh | 35 ++++++++++++++++++++++----------- 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 38fd07126..3874a2c3f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -809,7 +809,7 @@ checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "cli" -version = "0.1.0" +version = "0.0.0" dependencies = [ "bcrypt", "clap", @@ -2778,7 +2778,7 @@ dependencies = [ [[package]] name = "integrations" -version = "0.1.0" +version = "0.0.0" dependencies = [ "async-trait", "dotenv", @@ -4451,7 +4451,7 @@ dependencies = [ [[package]] name = "prisma-cli" -version = "0.1.0" +version = "0.0.0" dependencies = [ "prisma-client-rust-cli", ] diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index e749302b6..a87711a3a 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cli" -version = "0.1.0" +version = "0.0.0" edition = "2021" [[bin]] diff --git a/crates/integrations/Cargo.toml b/crates/integrations/Cargo.toml index e438e9d2c..56afd2db7 100644 --- a/crates/integrations/Cargo.toml +++ b/crates/integrations/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "integrations" -version = "0.1.0" +version = "0.0.0" edition = "2021" [dependencies] diff --git a/crates/prisma-cli/Cargo.toml b/crates/prisma-cli/Cargo.toml index 7d621ef7e..f63dce428 100644 --- a/crates/prisma-cli/Cargo.toml +++ b/crates/prisma-cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "prisma-cli" -version = "0.1.0" +version = "0.0.0" edition = "2021" [dependencies] diff --git a/scripts/release/bump-version.sh b/scripts/release/bump-version.sh index 41aa328c6..3857b900a 100755 --- a/scripts/release/bump-version.sh +++ b/scripts/release/bump-version.sh @@ -2,26 +2,37 @@ # https://github.com/pksunkara/cargo-workspaces#version _BUMP=${BUMP:?bump is required} -_GENERATE_CHANGELOG=${GENERATE_CHANGELOG:=0} +_GENERATE_CHANGELOG=${GENERATE_CHANGELOG:=1} -# desktop,mobile,core -_TARGETS=${TARGETS:=$@} +# desktop, mobile, core -> default is core +_TARGETS=${TARGETS:=core} -# SCRIPTS_DIR="${BASH_SOURCE%/*}/.." -# source "${SCRIPTS_DIR}/lib" - -# TODO: implement some sort of release system! This is all scratch work - - -# if no targets, exit +# If no targets are specified, exit. This _shouldn't_ happen since the default is core if [ -z "$_TARGETS" ]; then echo "No targets specified. Exiting..." exit 1 fi -# TODO: bump based on targets!! -# cargo workspaces version $BUMP --no-git-commit +if [[ $_TARGETS == *"core"* ]]; then + # Bump the Cargo workspaces version, this is interactive + cargo workspaces version $BUMP --no-git-commit + + # Get the current version in the root package.json + _VERSION=$(jq -r '.version' package.json) + + # Update the version according to the bump (major, minor, patch) + _NEW_VERSION=$(pnpx semver $_VERSION -i $_BUMP) + + # Update the version in the root package.json and in: (apps/*/package.json, packages/*/package.json, interface/package.json) + PATHS=("package.json" "apps/*/package.json" "packages/*/package.json" "interface/package.json") + for path in ${PATHS[@]}; do + jq ".version = \"$_NEW_VERSION\"" $path > tmp.$$.json && mv tmp.$$.json $path + done + + # Fix the formatting of the JSON files from the previous step + pnpm prettify +fi # https://docs.gitmoji-changelog.dev/#/?id=%f0%9f%93%9a-how-it-works if [ $_GENERATE_CHANGELOG == 1 ]; then From 3e5783939d43fe16ce40590646231419550b3e92 Mon Sep 17 00:00:00 2001 From: Aaron Leopold <36278431+aaronleopold@users.noreply.github.com> Date: Wed, 7 Feb 2024 16:19:48 -0700 Subject: [PATCH 2/8] WIP: start moving unused nightly steps to release ci --- .github/actions/build-docker/action.yml | 1 + .github/workflows/nightly.yml | 119 ------------------------ .github/workflows/release.yml | 95 +++++++++++++++++++ 3 files changed, 96 insertions(+), 119 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/actions/build-docker/action.yml b/.github/actions/build-docker/action.yml index c78951180..606a13daf 100644 --- a/.github/actions/build-docker/action.yml +++ b/.github/actions/build-docker/action.yml @@ -80,6 +80,7 @@ runs: push: ${{ inputs.push }} tags: ${{ env.TAGS }} + # TODO: detatch this from the action, make it separate as to notify on entire workflow success - name: Discord notification if: ${{ success() && inputs.push == 'true' }} env: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 4f4a1e944..41989bb95 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -47,122 +47,3 @@ jobs: push: ${{ env.PUSH }} platforms: ${{ env.PLATFORMS }} discord-webhook: ${{ secrets.DISCORD_WEBHOOK }} - - # TODO: build executables for apple(x86_64,darwin?),linux(x86_64,arm64?), and windows(x86_64) - # These should be uploaded to the nightly release as artifacts. Old artifacts should be deleted - # before uploading new ones. - - build-web: - name: Bundle web app - runs-on: [self-hosted] - if: false # TODO: don't do that - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Build web - uses: ./.github/actions/build-web - - - name: Upload web build - uses: ./.github/actions/upload-artifact - with: - upload-name: webapp - upload-path: apps/web/dist - - build-linux-server: - name: Compile server app (self-hosted linux) - needs: build-web - runs-on: [self-hosted] - if: false # TODO: don't do that - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Build server - uses: ./.github/actions/build-server - with: - platform: 'linux' - - - name: Upload stump server - uses: ./.github/actions/upload-artifact - with: - upload-name: stump_server-linux - upload-path: target/release/stump_server - - build-server: - strategy: - fail-fast: true - matrix: - platform: [macos, windows] - name: Compile server app - needs: build-web - runs-on: ${{ matrix.platform }} - if: false # TODO: don't do that - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Build server - uses: ./.github/actions/build-server - with: - platform: ${{ matrix.platform }} - - - name: Upload stump server - uses: ./.github/actions/upload-artifact - with: - upload-name: stump_server-${{ matrix.platform }} - upload-path: target/release/stump_server - - # build-linux-desktop: - # name: Compile desktop app (self-hosted linux) - # needs: build-web - # runs-on: [self-hosted] - # if: false # TODO: don't do that - # steps: - # - name: Checkout repository - # uses: actions/checkout@v3 - - # - name: Build desktop - # uses: ./.github/actions/build-desktop - # with: - # platform: 'linux' - - # - name: Upload desktop - # uses: ./.github/actions/upload-artifact - # with: - # upload-name: stump-desktop-linux - # upload-path: target/release/bundle - - build-desktop: - strategy: - fail-fast: true - matrix: - platform: [macos, windows] - name: Compile desktop app - needs: build-web - runs-on: ${{ matrix.platform }} - if: false # TODO: don't do that - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Build desktop - uses: ./.github/actions/build-desktop - with: - platform: ${{ matrix.platform }} - - # https://github.com/tauri-apps/tauri-action - # - uses: tauri-apps/tauri-action@v0 - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # tagName: stump-desktop-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version - # releaseName: 'Stump Desktop v__VERSION__' - # releaseBody: 'See the assets to download this version and install.' - # releaseDraft: true - # prerelease: true - - # - name: Upload desktop - # uses: ./.github/actions/upload-artifact - # with: - # upload-name: stump-desktop-${{ matrix.platform }} - # upload-path: target/release/bundle diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..efffedd41 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,95 @@ +name: 'Release CI' + +on: + push: + tags: + - 'v*.*.*' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} + +jobs: + build-docker: + name: Build docker image + runs-on: [self-hosted] + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Build and push docker image + uses: ./.github/actions/build-docker + with: + username: ${{ env.DOCKER_USERNAME }} + password: ${{ env.DOCKER_PASSWORD }} + tags: ${{ github.ref }} + load: false + push: true + platforms: 'linux/arm64/v8,linux/amd64' + discord-webhook: ${{ secrets.DISCORD_WEBHOOK }} + + build-web-app: + name: Build web app + runs-on: [self-hosted] + if: false # TODO: Enable this once 0.1.0 is ready + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Build the app + uses: ./.github/actions/build-web + + - name: Upload the build + uses: ./.github/actions/upload-artifact + with: + upload-name: webapp + upload-path: apps/web/dist + + build-server: + strategy: + fail-fast: true + matrix: + platform: [macos, windows] + name: Build server app + needs: build-web + runs-on: ${{ matrix.platform }} + if: false # TODO: Enable this once 0.1.0 is ready + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Build the server + uses: ./.github/actions/build-server + with: + platform: ${{ matrix.platform }} + + - name: Upload the server binary + uses: ./.github/actions/upload-artifact + with: + upload-name: stump_server-${{ matrix.platform }} + upload-path: target/release/stump_server + + # TODO: Investigate if I can just merge this with the above + build-linux-server: + name: Build server app (self-hosted runner) + needs: build-web + runs-on: [self-hosted] + if: false # TODO: Enable this once 0.1.0 is ready + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Build the server + uses: ./.github/actions/build-server + with: + platform: 'linux' + + - name: Upload the server binary + uses: ./.github/actions/upload-artifact + with: + upload-name: stump_server-linux + upload-path: target/release/stump_server From dfd0e5640dab4c8aaad0bbe9a6f8f80e116d2b37 Mon Sep 17 00:00:00 2001 From: Aaron Leopold <36278431+aaronleopold@users.noreply.github.com> Date: Thu, 8 Feb 2024 16:13:03 -0700 Subject: [PATCH 3/8] Does this work? --- .github/actions/build-docker/action.yml | 1 - .github/workflows/nightly.yml | 3 +- .github/workflows/release.yml | 155 ++++++++++++++---------- 3 files changed, 96 insertions(+), 63 deletions(-) diff --git a/.github/actions/build-docker/action.yml b/.github/actions/build-docker/action.yml index 606a13daf..c78951180 100644 --- a/.github/actions/build-docker/action.yml +++ b/.github/actions/build-docker/action.yml @@ -80,7 +80,6 @@ runs: push: ${{ inputs.push }} tags: ${{ env.TAGS }} - # TODO: detatch this from the action, make it separate as to notify on entire workflow success - name: Discord notification if: ${{ success() && inputs.push == 'true' }} env: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 41989bb95..9833dc4ad 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -17,7 +17,8 @@ env: DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} jobs: - docker-build: + nightly-docker-build: + if: github.event_name == 'pull_request' || github.ref == 'refs/heads/develop' name: Build docker image runs-on: [self-hosted] steps: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index efffedd41..7c8864f73 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,9 +1,13 @@ name: 'Release CI' +# This workflow triggers when a PR is merged into `main`, but jobs have conditions to only run when: +# - A PR is closed, merged into `main`, from a branch that matches the pattern `release/v*.*.*` + on: - push: - tags: - - 'v*.*.*' + pull_request: + branches: + - main + types: [opened, closed] concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -14,9 +18,38 @@ env: DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} jobs: - build-docker: + parse-semver: + if: contains(github.event.pull_request.head.ref, 'release/v') + name: Parse semver version from tag + runs-on: [self-hosted] + steps: + - name: Get the tag + id: tag + uses: ildug/get-tag-action@v1 + + - name: Print the tag + run: echo "The output version is ${{ steps.tag.outputs.version }}" + + - name: Configure docker tags + run: | + echo "DOCKER_TAGS=latest,${{ steps.tag.outputs.version }}" >> $GITHUB_ENV + echo "Docker tags are latest, nightly, and ${{ steps.tag.outputs.version }}" + + push-or-load: + if: contains(github.event.pull_request.head.ref, 'release/v') + name: Configure docker load/push + runs-on: [self-hosted] + steps: + - name: Configure environment + run: | + echo "load=${{ github.event.pull_request.merged == false }}" >> $GITHUB_OUTPUT + echo "push=${{ github.event.pull_request.merged == true }}" >> $GITHUB_OUTPUT + + build-stable-docker: + if: contains(github.event.pull_request.head.ref, 'release/v') name: Build docker image runs-on: [self-hosted] + needs: [parse-semver, push-or-load] steps: - name: Checkout repository uses: actions/checkout@v3 @@ -26,70 +59,70 @@ jobs: with: username: ${{ env.DOCKER_USERNAME }} password: ${{ env.DOCKER_PASSWORD }} - tags: ${{ github.ref }} - load: false - push: true + tags: ${{ env.DOCKER_TAGS }} + load: ${{ steps.push-or-load.outputs.load }} + push: ${{ steps.push-or-load.outputs.push }} platforms: 'linux/arm64/v8,linux/amd64' discord-webhook: ${{ secrets.DISCORD_WEBHOOK }} - build-web-app: - name: Build web app - runs-on: [self-hosted] - if: false # TODO: Enable this once 0.1.0 is ready - steps: - - name: Checkout repository - uses: actions/checkout@v3 + # build-web-app: + # name: Build web app + # runs-on: [self-hosted] + # if: false # TODO: Enable this once 0.1.0 is ready + # steps: + # - name: Checkout repository + # uses: actions/checkout@v3 - - name: Build the app - uses: ./.github/actions/build-web + # - name: Build the app + # uses: ./.github/actions/build-web - - name: Upload the build - uses: ./.github/actions/upload-artifact - with: - upload-name: webapp - upload-path: apps/web/dist - - build-server: - strategy: - fail-fast: true - matrix: - platform: [macos, windows] - name: Build server app - needs: build-web - runs-on: ${{ matrix.platform }} - if: false # TODO: Enable this once 0.1.0 is ready - steps: - - name: Checkout repository - uses: actions/checkout@v3 + # - name: Upload the build + # uses: ./.github/actions/upload-artifact + # with: + # upload-name: webapp + # upload-path: apps/web/dist - - name: Build the server - uses: ./.github/actions/build-server - with: - platform: ${{ matrix.platform }} + # build-server: + # strategy: + # fail-fast: true + # matrix: + # platform: [macos, windows] + # name: Build server app + # needs: build-web + # runs-on: ${{ matrix.platform }} + # if: false # TODO: Enable this once 0.1.0 is ready + # steps: + # - name: Checkout repository + # uses: actions/checkout@v3 - - name: Upload the server binary - uses: ./.github/actions/upload-artifact - with: - upload-name: stump_server-${{ matrix.platform }} - upload-path: target/release/stump_server + # - name: Build the server + # uses: ./.github/actions/build-server + # with: + # platform: ${{ matrix.platform }} - # TODO: Investigate if I can just merge this with the above - build-linux-server: - name: Build server app (self-hosted runner) - needs: build-web - runs-on: [self-hosted] - if: false # TODO: Enable this once 0.1.0 is ready - steps: - - name: Checkout repository - uses: actions/checkout@v3 + # - name: Upload the server binary + # uses: ./.github/actions/upload-artifact + # with: + # upload-name: stump_server-${{ matrix.platform }} + # upload-path: target/release/stump_server - - name: Build the server - uses: ./.github/actions/build-server - with: - platform: 'linux' + # # TODO: Investigate if I can just merge this with the above + # build-linux-server: + # name: Build server app (self-hosted runner) + # needs: build-web + # runs-on: [self-hosted] + # if: false # TODO: Enable this once 0.1.0 is ready + # steps: + # - name: Checkout repository + # uses: actions/checkout@v3 - - name: Upload the server binary - uses: ./.github/actions/upload-artifact - with: - upload-name: stump_server-linux - upload-path: target/release/stump_server + # - name: Build the server + # uses: ./.github/actions/build-server + # with: + # platform: 'linux' + + # - name: Upload the server binary + # uses: ./.github/actions/upload-artifact + # with: + # upload-name: stump_server-linux + # upload-path: target/release/stump_server From 1984b2f4dfa62a967ad93757ee1f9d7506d48cfd Mon Sep 17 00:00:00 2001 From: Aaron Leopold <36278431+aaronleopold@users.noreply.github.com> Date: Thu, 8 Feb 2024 16:17:31 -0700 Subject: [PATCH 4/8] add nightly --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7c8864f73..b6275933a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,7 +32,7 @@ jobs: - name: Configure docker tags run: | - echo "DOCKER_TAGS=latest,${{ steps.tag.outputs.version }}" >> $GITHUB_ENV + echo "DOCKER_TAGS=latest,nightly,${{ steps.tag.outputs.version }}" >> $GITHUB_ENV echo "Docker tags are latest, nightly, and ${{ steps.tag.outputs.version }}" push-or-load: From d1b74e89de5fa35239e38ddae4bc530f76afc3ba Mon Sep 17 00:00:00 2001 From: Aaron Leopold <36278431+aaronleopold@users.noreply.github.com> Date: Thu, 8 Feb 2024 16:18:35 -0700 Subject: [PATCH 5/8] ugh --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b6275933a..695a7718f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,6 +23,7 @@ jobs: name: Parse semver version from tag runs-on: [self-hosted] steps: + # FIXME: I realize this is for tags and won't work... - name: Get the tag id: tag uses: ildug/get-tag-action@v1 From f09222cb1924d19bf692386927a6655700407c74 Mon Sep 17 00:00:00 2001 From: Aaron Leopold <36278431+aaronleopold@users.noreply.github.com> Date: Thu, 8 Feb 2024 16:20:08 -0700 Subject: [PATCH 6/8] Try sed command --- .github/workflows/release.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 695a7718f..9a1935e26 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,10 +23,9 @@ jobs: name: Parse semver version from tag runs-on: [self-hosted] steps: - # FIXME: I realize this is for tags and won't work... - - name: Get the tag + - name: Extract version from branch name id: tag - uses: ildug/get-tag-action@v1 + run: echo "version=$(echo ${{ github.event.pull_request.head.ref }} | sed -e 's/release\/v//')" >> $GITHUB_ENV - name: Print the tag run: echo "The output version is ${{ steps.tag.outputs.version }}" From 390f62f815c0f6f066824ccb49247edd95e345c2 Mon Sep 17 00:00:00 2001 From: Aaron Leopold <36278431+aaronleopold@users.noreply.github.com> Date: Thu, 8 Feb 2024 16:21:18 -0700 Subject: [PATCH 7/8] Name kms --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9a1935e26..d2aaa6611 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ env: jobs: parse-semver: if: contains(github.event.pull_request.head.ref, 'release/v') - name: Parse semver version from tag + name: Parse semver version runs-on: [self-hosted] steps: - name: Extract version from branch name From 973a81b9f2291c5cb38e66972c21159601131215 Mon Sep 17 00:00:00 2001 From: Aaron Leopold <36278431+aaronleopold@users.noreply.github.com> Date: Thu, 8 Feb 2024 16:24:36 -0700 Subject: [PATCH 8/8] remove if for nightly --- .github/workflows/nightly.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 9833dc4ad..aae932f27 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -18,7 +18,6 @@ env: jobs: nightly-docker-build: - if: github.event_name == 'pull_request' || github.ref == 'refs/heads/develop' name: Build docker image runs-on: [self-hosted] steps: