From ff92af42a80b5a6efc2f10d210d258c3fc3f31c9 Mon Sep 17 00:00:00 2001 From: Taylor Beeston Date: Sat, 27 Jul 2024 12:06:46 -0700 Subject: [PATCH] :bookmark: Create release pipeline --- .github/workflows/release.yaml | 78 ++++++++++++++++++++++++++++++++++ PKGBUILD.template | 30 +++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 .github/workflows/release.yaml create mode 100644 PKGBUILD.template diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..f2adc29 --- /dev/null +++ b/.github/workflows/release.yaml @@ -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 diff --git a/PKGBUILD.template b/PKGBUILD.template new file mode 100644 index 0000000..400292f --- /dev/null +++ b/PKGBUILD.template @@ -0,0 +1,30 @@ +# Maintainer: Taylor Beeston +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" +}