Skip to content

Use model aliases instead of dated snapshot IDs #14

Use model aliases instead of dated snapshot IDs

Use model aliases instead of dated snapshot IDs #14

Workflow file for this run

name: Release

Check failure on line 1 in .github/workflows/release.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/release.yml

Invalid workflow file

(Line: 149, Col: 13): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.AUR_SSH_KEY != ''
on:
push:
tags:
- 'v*'
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact: jcode-linux-x86_64
- os: macos-latest
target: aarch64-apple-darwin
artifact: jcode-macos-aarch64
steps:
- uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.DEPLOY_KEY }}
submodules: recursive
- name: Configure SSH for cargo git dependencies
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.DEPLOY_KEY }}
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
cache-all-crates: "true"
- name: Build release binary
run: |
mkdir -p .cargo
echo -e '[build]\nrustc-wrapper = ""' > .cargo/config.toml
cargo build --release --target ${{ matrix.target }}
env:
JCODE_RELEASE_BUILD: "1"
- name: Package binary
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/jcode dist/${{ matrix.artifact }}
chmod +x dist/${{ matrix.artifact }}
cd dist && tar czf ${{ matrix.artifact }}.tar.gz ${{ matrix.artifact }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: dist/${{ matrix.artifact }}.tar.gz
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: artifacts/**/*.tar.gz
- name: Update Homebrew formula
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
run: |
VERSION="${GITHUB_REF_NAME}"
VERSION_NUM="${VERSION#v}"
LINUX_SHA=$(sha256sum artifacts/jcode-linux-x86_64/jcode-linux-x86_64.tar.gz | cut -d' ' -f1)
MACOS_SHA=$(sha256sum artifacts/jcode-macos-aarch64/jcode-macos-aarch64.tar.gz | cut -d' ' -f1)
mkdir -p ~/.ssh
echo "$DEPLOY_KEY" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
export GIT_SSH_COMMAND="ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no"
git clone git@github.com:1jehuang/homebrew-jcode.git /tmp/homebrew-jcode
cat > /tmp/homebrew-jcode/Formula/jcode.rb << FORMULA
class Jcode < Formula
desc "AI coding agent powered by Claude and ChatGPT"
homepage "https://github.com/1jehuang/jcode"
version "${VERSION_NUM}"
license "MIT"
on_macos do
on_arm do
url "https://github.com/1jehuang/jcode/releases/download/${VERSION}/jcode-macos-aarch64.tar.gz"
sha256 "${MACOS_SHA}"
def install
bin.install "jcode-macos-aarch64" => "jcode"
end
end
end
on_linux do
on_intel do
url "https://github.com/1jehuang/jcode/releases/download/${VERSION}/jcode-linux-x86_64.tar.gz"
sha256 "${LINUX_SHA}"
def install
bin.install "jcode-linux-x86_64" => "jcode"
end
end
end
test do
assert_match "jcode", shell_output("#{bin}/jcode --version")
end
end
FORMULA
sed -i 's/^ //' /tmp/homebrew-jcode/Formula/jcode.rb
cd /tmp/homebrew-jcode
git config user.name "jcode-release-bot"
git config user.email "release@jcode.dev"
git add Formula/jcode.rb
git commit -m "Update to ${VERSION}" || echo "No changes"
git push
- name: Update AUR package
if: ${{ secrets.AUR_SSH_KEY != '' }}
env:
AUR_SSH_KEY: ${{ secrets.AUR_SSH_KEY }}
run: |
VERSION="${GITHUB_REF_NAME}"
VERSION_NUM="${VERSION#v}"
LINUX_SHA=$(sha256sum artifacts/jcode-linux-x86_64/jcode-linux-x86_64.tar.gz | cut -d' ' -f1)
LINUX_URL="https://github.com/1jehuang/jcode/releases/download/${VERSION}/jcode-linux-x86_64.tar.gz"
mkdir -p ~/.ssh
echo "$AUR_SSH_KEY" > ~/.ssh/aur_key
chmod 600 ~/.ssh/aur_key
echo -e "Host aur.archlinux.org\n IdentityFile ~/.ssh/aur_key\n User aur\n StrictHostKeyChecking no" >> ~/.ssh/config
git clone ssh://aur@aur.archlinux.org/jcode-bin.git /tmp/jcode-aur
cat > /tmp/jcode-aur/PKGBUILD << 'PKGBUILD_END'
# Maintainer: Jeremy Huang <jeremyhuang55555@gmail.com>
pkgname=jcode-bin
pkgver=VERSION_PLACEHOLDER
pkgrel=1
pkgdesc="AI coding agent powered by Claude and ChatGPT"
arch=('x86_64')
url="https://github.com/1jehuang/jcode"
license=('MIT')
provides=('jcode')
conflicts=('jcode')
source=("URL_PLACEHOLDER")
sha256sums=('SHA_PLACEHOLDER')
package() {
install -Dm755 "${srcdir}/jcode-linux-x86_64" "${pkgdir}/usr/bin/jcode"
}
PKGBUILD_END
sed -i "s|VERSION_PLACEHOLDER|${VERSION_NUM}|" /tmp/jcode-aur/PKGBUILD
sed -i "s|URL_PLACEHOLDER|${LINUX_URL}|" /tmp/jcode-aur/PKGBUILD
sed -i "s|SHA_PLACEHOLDER|${LINUX_SHA}|" /tmp/jcode-aur/PKGBUILD
sed -i 's/^ //' /tmp/jcode-aur/PKGBUILD
# Generate .SRCINFO without makepkg
cat > /tmp/jcode-aur/.SRCINFO << SRCINFO
pkgbase = jcode-bin
pkgdesc = AI coding agent powered by Claude and ChatGPT
pkgver = ${VERSION_NUM}
pkgrel = 1
url = https://github.com/1jehuang/jcode
arch = x86_64
license = MIT
provides = jcode
conflicts = jcode
source = ${LINUX_URL}
sha256sums = ${LINUX_SHA}
pkgname = jcode-bin
SRCINFO
sed -i 's/^ //' /tmp/jcode-aur/.SRCINFO
cd /tmp/jcode-aur
git config user.name "Jeremy Huang"
git config user.email "jeremyhuang55555@gmail.com"
git add PKGBUILD .SRCINFO
git commit -m "Update to ${VERSION}" || echo "No changes"
git push