Skip to content

Commit

Permalink
🔖 Create release pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
TaylorBeeston committed Jul 27, 2024
1 parent a495176 commit ff92af4
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: CI/CD Pipeline

on:
push:
branches: [publish, release]

jobs:
test_and_build:
if: github.ref == 'refs/heads/publish'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Run tests
run: cargo test
- name: Build
run: cargo build --release
- name: Increment version
id: version
run: |
current_version=$(grep version Cargo.toml | sed 's/.*= "//' | sed 's/"//')
new_version=$(echo $current_version | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g')
sed -i "s/version = \"$current_version\"/version = \"$new_version\"/" Cargo.toml
echo "NEW_VERSION=$new_version" >> $GITHUB_ENV
git config user.name github-actions
git config user.email github-actions@github.com
git add Cargo.toml
git commit -m "Bump version to $new_version"
- name: Push to release branch
run: |
git push origin HEAD:release
publish_crates_and_aur:
if: github.ref == 'refs/heads/release'
needs: test_and_build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable

- name: Publish to crates.io
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
run: cargo publish --token ${CRATES_IO_TOKEN}

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}

- name: Update PKGBUILD
run: |
version=$(grep version Cargo.toml | sed 's/.*= "//' | sed 's/"//')
sed "s/pkgver=.*/pkgver=$version/" PKGBUILD.template > PKGBUILD
# Download the source and calculate its SHA256 sum
curl -sL "https://crates.io/api/v1/crates/image-colorizer/$version/download" -o "$pkgname-$version.tar.gz"
sum=$(sha256sum "$pkgname-$version.tar.gz" | cut -d ' ' -f 1)
sed -i "s/sha256sums=('PLACEHOLDER')/sha256sums=('$sum')/" PKGBUILD
- name: Publish AUR package
env:
SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
run: |
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/aur
chmod 600 ~/.ssh/aur
git config --global user.name "Taylor Beeston"
git config --global user.email "beeston.taylor@gmail.com"
git clone ssh://aur@aur.archlinux.org/image-colorizer.git aur-repo
cp PKGBUILD aur-repo/
cd aur-repo
git add PKGBUILD
git commit -S -m "Update to version $version"
git push
30 changes: 30 additions & 0 deletions PKGBUILD.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Maintainer: Taylor Beeston <beeston.taylor@gmail.com>
pkgname=image-colorizer
pkgver=VERSION
pkgrel=1
pkgdesc="Snap an image to a colorscheme extremely quickly"
arch=('x86_64')
url="https://github.com/TaylorBeeston/image-colorizer"
license=('MIT')
depends=('gcc-libs' 'vulkan-icd-loader')
makedepends=('rust' 'cargo' 'vulkan-headers')
optdepends=(
'mesa: for OpenGL and Vulkan support on Intel and AMD GPUs'
'nvidia-utils: for Vulkan support on NVIDIA GPUs'
'vulkan-intel: for Vulkan support on Intel GPUs'
'vulkan-radeon: for Vulkan support on AMD GPUs'
'wgpu-git: WebGPU implementation (AUR)'
)
source=("$pkgname-$pkgver.tar.gz::https://crates.io/api/v1/crates/$pkgname/$pkgver/download")
sha256sums=('PLACEHOLDER') # This will be replaced with the actual checksum in CI

build() {
cd "$pkgname-$pkgver"
cargo build --release --locked
}

package() {
cd "$pkgname-$pkgver"
install -Dm755 "target/release/$pkgname" "$pkgdir/usr/bin/$pkgname"
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

0 comments on commit ff92af4

Please sign in to comment.