Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👷 Define release workflow #263

Merged
merged 10 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
121 changes: 1 addition & 120 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
128 changes: 128 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cli"
version = "0.1.0"
version = "0.0.0"
edition = "2021"

[[bin]]
Expand Down
2 changes: 1 addition & 1 deletion crates/integrations/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "integrations"
version = "0.1.0"
version = "0.0.0"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/prisma-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "prisma-cli"
version = "0.1.0"
version = "0.0.0"
edition = "2021"

[dependencies]
Expand Down
35 changes: 23 additions & 12 deletions scripts/release/bump-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down