ci: release builder script and release workflow
3 files changed, +116 -1
+80-0.github/workflows/release.yml
| @@ -0,0 +1,80 @@ | ||
| 1 | +name: Release | |
| 2 | + | |
| 3 | +on: | |
| 4 | + push: | |
| 5 | + tags: | |
| 6 | + - "v*" | |
| 7 | + | |
| 8 | +permissions: | |
| 9 | + contents: write | |
| 10 | + | |
| 11 | +jobs: | |
| 12 | + build: | |
| 13 | + strategy: | |
| 14 | + matrix: | |
| 15 | + include: | |
| 16 | + - os: ubuntu-latest | |
| 17 | + target: x86_64-unknown-linux-gnu | |
| 18 | + name: jv-linux-x86_64 | |
| 19 | + - os: macos-latest | |
| 20 | + target: aarch64-apple-darwin | |
| 21 | + name: jv-macos-aarch64 | |
| 22 | + - os: macos-latest | |
| 23 | + target: x86_64-apple-darwin | |
| 24 | + name: jv-macos-x86_64 | |
| 25 | + - os: windows-latest | |
| 26 | + target: x86_64-pc-windows-msvc | |
| 27 | + name: jv-windows-x86_64 | |
| 28 | + | |
| 29 | + runs-on: ${{ matrix.os }} | |
| 30 | + | |
| 31 | + steps: | |
| 32 | + - uses: actions/checkout@v4 | |
| 33 | + | |
| 34 | + - name: Install Rust toolchain | |
| 35 | + run: rustup target add ${{ matrix.target }} | |
| 36 | + | |
| 37 | + - name: Install Linux dependencies | |
| 38 | + if: matrix.os == 'ubuntu-latest' | |
| 39 | + run: | | |
| 40 | + sudo apt-get update | |
| 41 | + sudo apt-get install -y libgtk-3-dev libxdo-dev libatk1.0-dev libglib2.0-dev | |
| 42 | + | |
| 43 | + - name: Build | |
| 44 | + run: cargo build --release --target ${{ matrix.target }} | |
| 45 | + | |
| 46 | + - name: Package (Unix) | |
| 47 | + if: matrix.os != 'windows-latest' | |
| 48 | + run: | | |
| 49 | + mkdir -p jv/bin | |
| 50 | + cp target/${{ matrix.target }}/release/jv jv/bin/ | |
| 51 | + tar czf ${{ matrix.name }}.tar.gz jv | |
| 52 | + | |
| 53 | + - name: Package (Windows) | |
| 54 | + if: matrix.os == 'windows-latest' | |
| 55 | + shell: bash | |
| 56 | + run: | | |
| 57 | + mkdir -p jv/bin | |
| 58 | + cp target/${{ matrix.target }}/release/jv.exe jv/bin/ | |
| 59 | + tar czf ${{ matrix.name }}.tar.gz jv | |
| 60 | + | |
| 61 | + - name: Upload artifact | |
| 62 | + uses: actions/upload-artifact@v4 | |
| 63 | + with: | |
| 64 | + name: ${{ matrix.name }} | |
| 65 | + path: ${{ matrix.name }}.tar.gz | |
| 66 | + | |
| 67 | + release: | |
| 68 | + needs: build | |
| 69 | + runs-on: ubuntu-latest | |
| 70 | + steps: | |
| 71 | + - name: Download all artifacts | |
| 72 | + uses: actions/download-artifact@v4 | |
| 73 | + with: | |
| 74 | + merge-multiple: true | |
| 75 | + | |
| 76 | + - name: Create release | |
| 77 | + uses: softprops/action-gh-release@v2 | |
| 78 | + with: | |
| 79 | + files: "*.tar.gz" | |
| 80 | + generate_release_notes: true |
+1-1Cargo.lock
| @@ -2078,7 +2078,7 @@ dependencies = [ | ||
| 2078 | 2078 | |
| 2079 | 2079 | [[package]] |
| 2080 | 2080 | name = "jv" |
| 2081 | -version = "0.1.0" | |
| 2081 | +version = "0.0.1" | |
| 2082 | 2082 | dependencies = [ |
| 2083 | 2083 | "base64 0.22.1", |
| 2084 | 2084 | "chrono", |
+35-0scripts/release.sh
| @@ -0,0 +1,35 @@ | ||
| 1 | +#!/bin/bash | |
| 2 | +# Author: Lane Henslee (huncho@hygo.ai) | |
| 3 | +# Bumps the version for relevant version files, auto commits them, and prompts a tag with editor. | |
| 4 | + | |
| 5 | +current_version="$(git tag -l | head -n 1 | sed 's/^v//')" | |
| 6 | +[[ -z "$current_version" ]] && current_version=0.0.0 | |
| 7 | +echo -e "\033[35mCurrently on version $current_version\033[0m" | |
| 8 | + | |
| 9 | +IFS='.' read -r major minor patch <<<"$current_version" | |
| 10 | + | |
| 11 | +case "$1" in | |
| 12 | +same) echo -e "\033[34mKeeping the same version\033[0m" ;; | |
| 13 | +major) major=$((major + 1)) && minor=0 && patch=0 ;; | |
| 14 | +minor) minor=$((minor + 1)) && patch=$((patch + 1)) ;; | |
| 15 | +*) patch=$((patch + 1)) ;; | |
| 16 | +esac | |
| 17 | + | |
| 18 | +new_version="$major.$minor.$patch" | |
| 19 | + | |
| 20 | +echo -e "\033[32mUpdating version $new_version\033[0m" | |
| 21 | + | |
| 22 | +printf "\033[37m(y/n) Would you like to continue? Defaults to y: \033[0m" | |
| 23 | +read -rp "" yn | |
| 24 | +{ [[ "$yn" == "y" ]] || [[ -z "$yn" ]]; } || { echo -e "\033[31mAborting...\033[0m" && exit 0; } | |
| 25 | + | |
| 26 | +find . -name Cargo.toml -exec sed -i "s/^version.*/version = \"$new_version\"/" {} \; | |
| 27 | +find . -name Cargo.toml -exec git add {} \; | |
| 28 | +find . -name package.json -exec sed -i "s/\"version\".*/\"version\": \"$new_version\"/" {} \; | |
| 29 | +find . -name package.json -exec git add {} \; | |
| 30 | + | |
| 31 | +echo -e "\033[37mUpdated relevant files. Create new commit\033[0m" | |
| 32 | +git commit -m "version tag" | |
| 33 | + | |
| 34 | +echo -e "\033[37mCompleted commit. Create new tag\033[0m" | |
| 35 | +git tag -f -a "v$new_version" |