diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 4f4a1e944..aae932f27 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -17,7 +17,7 @@ env: DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} jobs: - docker-build: + nightly-docker-build: name: Build docker image runs-on: [self-hosted] steps: @@ -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..d2aaa6611 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,128 @@ +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: + pull_request: + branches: + - main + types: [opened, closed] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} + +jobs: + parse-semver: + if: contains(github.event.pull_request.head.ref, 'release/v') + name: Parse semver version + runs-on: [self-hosted] + steps: + - name: Extract version from branch name + id: tag + 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 }}" + + - name: Configure docker tags + run: | + 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: + 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 + + - name: Build and push docker image + uses: ./.github/actions/build-docker + with: + username: ${{ env.DOCKER_USERNAME }} + password: ${{ env.DOCKER_PASSWORD }} + 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 + + # - 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 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