ci: switch release workflow to Forgejo, update repo URLs
Some checks failed
Release / release (push) Failing after 59s
Some checks failed
Release / release (push) Failing after 59s
- Add Forgejo release workflow with .deb, Homebrew tap and APT updates. - Remove obsolete GitHub Actions release workflow. - Update Cargo.toml repository and homepage URLs to git.janvete.com.
This commit is contained in:
parent
57f734c41a
commit
13081b4d4a
3 changed files with 207 additions and 36 deletions
205
.forgejo/workflows/release.yml
Normal file
205
.forgejo/workflows/release.yml
Normal file
|
|
@ -0,0 +1,205 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: rust:bookworm
|
||||
volumes:
|
||||
- /root/.ssh:/root/.ssh:ro
|
||||
|
||||
steps:
|
||||
- name: Install tools
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y dpkg-dev git curl openssh-client
|
||||
cargo install cargo-deb
|
||||
|
||||
- name: Setup SSH
|
||||
run: |
|
||||
echo "GIT_SSH_COMMAND=ssh -p 554 -i /root/.ssh/forgejo_runner -o StrictHostKeyChecking=no" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Checkout source
|
||||
run: |
|
||||
git clone ssh://git@git-ssh.janvete.com:554/seth/lines.git src
|
||||
cd src
|
||||
git checkout "${{ github.ref_name }}"
|
||||
|
||||
- name: Build release binaries and .deb
|
||||
working-directory: src
|
||||
run: |
|
||||
VERSION=${{ github.ref_name }}
|
||||
mkdir -p dist
|
||||
|
||||
# Linux amd64 binary + .deb
|
||||
cargo build --release
|
||||
cargo deb --no-build
|
||||
cp target/debian/*.deb dist/
|
||||
|
||||
STAGING=$(mktemp -d)
|
||||
cp target/release/lines "${STAGING}/lines"
|
||||
tar -czf "dist/lines-${VERSION}-linux-amd64.tar.gz" -C "${STAGING}" lines
|
||||
rm -rf "${STAGING}"
|
||||
|
||||
# macOS cross-compilation
|
||||
rustup target add x86_64-apple-darwin aarch64-apple-darwin
|
||||
cargo install cargo-zigbuild
|
||||
cargo zigbuild --release --target x86_64-apple-darwin
|
||||
cargo zigbuild --release --target aarch64-apple-darwin
|
||||
|
||||
for arch in x86_64 aarch64; do
|
||||
STAGING=$(mktemp -d)
|
||||
cp "target/${arch}-apple-darwin/release/lines" "${STAGING}/lines"
|
||||
case "$arch" in
|
||||
x86_64) out_arch=amd64 ;;
|
||||
aarch64) out_arch=arm64 ;;
|
||||
esac
|
||||
tar -czf "dist/lines-${VERSION}-darwin-${out_arch}.tar.gz" -C "${STAGING}" lines
|
||||
rm -rf "${STAGING}"
|
||||
done
|
||||
|
||||
echo "=== SHA256 checksums ==="
|
||||
sha256sum dist/*
|
||||
|
||||
- name: Create Forgejo Release
|
||||
working-directory: src
|
||||
env:
|
||||
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
||||
FORGEJO_URL: https://git.janvete.com
|
||||
run: |
|
||||
VERSION=${{ github.ref_name }}
|
||||
API="${FORGEJO_URL}/api/v1/repos/seth/lines"
|
||||
|
||||
RELEASE_JSON=$(curl -sS -H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-X POST \
|
||||
-d "{\"tag_name\":\"${VERSION}\",\"name\":\"${VERSION}\",\"draft\":false,\"prerelease\":false}" \
|
||||
"${API}/releases")
|
||||
|
||||
echo "Create release response: ${RELEASE_JSON}"
|
||||
RELEASE_ID=$(echo "${RELEASE_JSON}" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
|
||||
|
||||
if [ -z "${RELEASE_ID}" ]; then
|
||||
echo "Release may already exist, fetching existing release..."
|
||||
EXISTING=$(curl -sS -H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||
"${API}/releases/tags/${VERSION}")
|
||||
echo "Existing release response: ${EXISTING}"
|
||||
RELEASE_ID=$(echo "${EXISTING}" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
|
||||
fi
|
||||
|
||||
if [ -z "${RELEASE_ID}" ]; then
|
||||
echo "Failed to create or fetch release"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for ARCHIVE in dist/*; do
|
||||
[ -e "${ARCHIVE}" ] || continue
|
||||
NAME=$(basename "${ARCHIVE}")
|
||||
case "${NAME}" in
|
||||
*.tar.gz) CONTENT_TYPE="application/gzip" ;;
|
||||
*.deb) CONTENT_TYPE="application/vnd.debian.binary-package" ;;
|
||||
*) CONTENT_TYPE="application/octet-stream" ;;
|
||||
esac
|
||||
curl -sS -H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||
-H "Content-Type: ${CONTENT_TYPE}" \
|
||||
--data-binary "@${ARCHIVE}" \
|
||||
"${API}/releases/${RELEASE_ID}/assets?name=${NAME}"
|
||||
echo "Uploaded ${NAME}"
|
||||
done
|
||||
|
||||
- name: Update Homebrew tap
|
||||
working-directory: src
|
||||
run: |
|
||||
VERSION=${{ github.ref_name }}
|
||||
VER=${VERSION#v}
|
||||
|
||||
SHA_DARWIN_ARM64=$(sha256sum dist/lines-${VERSION}-darwin-arm64.tar.gz | awk '{print $1}')
|
||||
SHA_DARWIN_AMD64=$(sha256sum dist/lines-${VERSION}-darwin-amd64.tar.gz | awk '{print $1}')
|
||||
SHA_LINUX=$(sha256sum dist/lines-${VERSION}-linux-amd64.tar.gz | awk '{print $1}')
|
||||
|
||||
git clone ssh://git@git-ssh.janvete.com:554/seth/homebrew-tools.git tap
|
||||
|
||||
cat > tap/Formula/lines.rb << FORMULA
|
||||
class Lines < Formula
|
||||
desc "TUI for running frequently used commands from markdown files"
|
||||
homepage "https://git.janvete.com/seth/lines"
|
||||
version "${VER}"
|
||||
license "MIT"
|
||||
head "https://git.janvete.com/seth/lines.git", branch: "main"
|
||||
|
||||
on_macos do
|
||||
if Hardware::CPU.arm?
|
||||
url "https://git.janvete.com/seth/lines/releases/download/${VERSION}/lines-${VERSION}-darwin-arm64.tar.gz"
|
||||
sha256 "${SHA_DARWIN_ARM64}"
|
||||
else
|
||||
url "https://git.janvete.com/seth/lines/releases/download/${VERSION}/lines-${VERSION}-darwin-amd64.tar.gz"
|
||||
sha256 "${SHA_DARWIN_AMD64}"
|
||||
end
|
||||
end
|
||||
|
||||
on_linux do
|
||||
if Hardware::CPU.intel?
|
||||
url "https://git.janvete.com/seth/lines/releases/download/${VERSION}/lines-${VERSION}-linux-amd64.tar.gz"
|
||||
sha256 "${SHA_LINUX}"
|
||||
end
|
||||
end
|
||||
|
||||
def install
|
||||
bin.install "lines"
|
||||
end
|
||||
|
||||
test do
|
||||
assert_match "TUI for running frequently used commands", shell_output("#{bin}/lines --help")
|
||||
end
|
||||
end
|
||||
FORMULA
|
||||
|
||||
cd tap
|
||||
git config user.email "forgejo-actions[bot]@janvete.com"
|
||||
git config user.name "forgejo-actions[bot]"
|
||||
git add Formula/lines.rb
|
||||
git commit -m "chore: bump lines to ${VERSION}"
|
||||
git push
|
||||
|
||||
- name: Update APT repository
|
||||
working-directory: src
|
||||
run: |
|
||||
VERSION=${{ github.ref_name }}
|
||||
|
||||
git clone ssh://git@git-ssh.janvete.com:554/seth/apt.git apt-repo
|
||||
cp dist/*.deb apt-repo/
|
||||
|
||||
cd apt-repo
|
||||
dpkg-scanpackages . > Packages
|
||||
gzip -k -f Packages
|
||||
|
||||
cat > Release << RELEASE
|
||||
Origin: janvete
|
||||
Label: janvete
|
||||
Suite: stable
|
||||
Codename: stable
|
||||
Version: 1.0
|
||||
Architectures: amd64
|
||||
Components: main
|
||||
Description: janvete tools APT repository
|
||||
Date: $(date -Ru)
|
||||
RELEASE
|
||||
|
||||
{
|
||||
echo "SHA256:"
|
||||
for f in Packages Packages.gz *.deb; do
|
||||
[ -e "$f" ] || continue
|
||||
printf " %s %16d %s\n" "$(sha256sum "$f" | cut -d' ' -f1)" "$(stat -c%s "$f")" "$f"
|
||||
done
|
||||
} >> Release
|
||||
|
||||
git config user.email "forgejo-actions[bot]@janvete.com"
|
||||
git config user.name "forgejo-actions[bot]"
|
||||
git add -A
|
||||
git commit -m "chore: add lines ${VERSION}"
|
||||
git push
|
||||
34
.github/workflows/release.yml
vendored
34
.github/workflows/release.yml
vendored
|
|
@ -1,34 +0,0 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build-deb:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Install cargo-deb
|
||||
run: cargo install cargo-deb
|
||||
|
||||
- name: Build release binary
|
||||
run: cargo build --release
|
||||
|
||||
- name: Build .deb package
|
||||
run: cargo deb --no-build
|
||||
|
||||
- name: Upload .deb to release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: target/debian/*.deb
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
|
@ -5,8 +5,8 @@ edition = "2024"
|
|||
authors = ["janvete"]
|
||||
description = "TUI for running frequently used commands"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/janvete/lines"
|
||||
homepage = "https://github.com/janvete/lines"
|
||||
repository = "https://git.janvete.com/seth/lines"
|
||||
homepage = "https://git.janvete.com/seth/lines"
|
||||
keywords = ["cli", "tui", "ssh", "commands"]
|
||||
categories = ["command-line-utilities"]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue