From 889295fd58b0a2cfcc8add99c6bc85de5d21dd19 Mon Sep 17 00:00:00 2001 From: Abraham Toriz Date: Sat, 26 Nov 2022 18:00:47 -0600 Subject: [PATCH] finish restructure of the CI pipelines --- .gitlab-ci.yml | 28 +++++++++++++++++++++++----- README.md | 13 +++++++++++-- scripts/build.sh | 33 ++++++++++++++++----------------- scripts/debpackage.sh | 5 ++--- scripts/release-aur-bin.sh | 17 +++++------------ scripts/release-aur-git.sh | 9 --------- 6 files changed, 57 insertions(+), 48 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ac1e0ab..1a48a18 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -93,13 +93,13 @@ release: assets: links: - name: 'Any linux binary' - url: '${PACKAGE_REGISTRY_URL}/tiempo-${CI_COMMIT_TAG:1}-x86_64.tar.gz' + url: '${PACKAGE_REGISTRY_URL}/tiempo-${CI_COMMIT_TAG}-x86_64.tar.gz' - name: 'Any linux binary sha256 sum' - url: '${PACKAGE_REGISTRY_URL}/tiempo-${CI_COMMIT_TAG:1}-x86_64.tar.gz.sum' + url: '${PACKAGE_REGISTRY_URL}/tiempo-${CI_COMMIT_TAG}-x86_64.tar.gz.sum' - name: 'Debian archive' - url: '${PACKAGE_REGISTRY_URL}/tiempo_${CI_COMMIT_TAG:1}_amd64.deb' + url: '${PACKAGE_REGISTRY_URL}/tiempo_${CI_COMMIT_TAG}_amd64.deb' - name: 'Debian archive sha256 sum' - url: '${PACKAGE_REGISTRY_URL}/tiempo_${CI_COMMIT_TAG:1}_amd64.deb.sum' + url: '${PACKAGE_REGISTRY_URL}/tiempo_${CI_COMMIT_TAG}_amd64.deb.sum' deploy:arch-bin: stage: aur @@ -113,8 +113,17 @@ deploy:arch-bin: # setup git, because we'll commit - git config --global user.name "$COMMITER_NAME" - git config --global user.email "$COMMITER_EMAIL" - # finally run the script + # Clone the repo + - git clone $BIN_REPO_URL $PROJECT_NAME-bin + # generate the PKGBUILD in the current directory - scripts/release-aur-bin.sh + - mv PKGBUILD $PROJECT_NAME-bin/ + - mv .SRCINFO $PROJECT_NAME-bin/ + # commit + - cd $PROJECT_NAME-bin + - git add . + - git commit -m "Release version $CI_COMMIT_TAG" + - git push rules: - if: $CI_COMMIT_BRANCH when: never @@ -132,8 +141,17 @@ deploy:arch-git: # setup git, because we'll commit - git config --global user.name "$COMMITER_NAME" - git config --global user.email "$COMMITER_EMAIL" + # clone the repo + - git clone $GIT_REPO_URL $PROJECT_NAME-git # finally run the script - scripts/release-aur-git.sh + - mv PKGBUILD $PROJECT_NAME-bin/ + - mv .SRCINFO $PROJECT_NAME-bin/ + # and commit + - cd $PROJECT_NAME-bin + - git add . + - git commit -m "Release version $VERSION" + - git push rules: - if: $CI_COMMIT_BRANCH when: never diff --git a/README.md b/README.md index 9f8ef35..67c101d 100644 --- a/README.md +++ b/README.md @@ -119,9 +119,18 @@ Or build it yourself from this repo: podman build -t tiempo-build-env . -Then build the packages: +Then build the artifacts: - podman run -it --rm -w /app -v ./:/app -e CI_COMMIT_TAG=v2.0.0 tiempo-build-env ./scripts/build.sh + podman run -it --rm -w /app -v ./:/app -v tiempo_cargo_index:/usr/local/cargo/registry -e CI_COMMIT_TAG=v1.6rc8 tiempo-build-env ./scripts/build.sh + +To build the archlinux PKGBUILDs (depends on the artifacts folder created by the +previous command): + + podman run -it --rm -w /app -v ./:/app:rw -e CI_COMMIT_TAG=v1.6rc8 -e CI_PROJECT_ID=27545092 --uidmap 1000:0:1 --uidmap 0:1:1000 categulario/makepkg ./scripts/release-aur-bin.sh + podman run -it --rm -w /app -v ./:/app:rw -e CI_COMMIT_TAG=v1.6rc8 --uidmap 1000:0:1 --uidmap 0:1:1000 categulario/makepkg ./scripts/release-aur-git.sh + +Both of the previous commands produce PKGBUILDs in the current directory so if +you run both sequentially you'll lose the PKGBUILD of the first command. ## Special Thanks diff --git a/scripts/build.sh b/scripts/build.sh index 693f4d6..61c2609 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -15,29 +15,28 @@ cargo clippy --all-targets --all-features -- -D warnings cargo test cargo build --locked --release -# create the tar package -mkdir -p build/bin build/share/doc/tiempo build/share/man/man1 build/share/bash-completion/completions build/share/zsh/site-functions build/share/fish/vendor_completions.d # move binary -cp target/release/t build/bin/ +install -m 755 -D target/release/t build/bin/t # move documentation -cp CHANGELOG.md build/share/doc/tiempo/ -cp README.md build/share/doc/tiempo/ -cp LICENSE build/share/doc/tiempo/ +install -m 644 -D CHANGELOG.md build/share/doc/tiempo/CHANGELOG.md +install -m 644 -D README.md build/share/doc/tiempo/README.md +install -m 644 -D LICENSE build/share/doc/tiempo/LICENSE # move man page -cp docs/build/man/tiempo.1.gz build/share/man/man1/ +install -m 644 -D docs/build/man/tiempo.1.gz build/share/man/man1/tiempo.1.gz # move completions -cp completions/bash/t build/share/bash-completion/completions/ -cp completions/fish/t.fish build/share/fish/vendor_completions.d/ -cp completions/zsh/_t build/share/zsh/site-functions/ +install -m 644 -D completions/bash/t build/share/bash-completion/completions/t +install -m 644 -D completions/fish/t.fish build/share/fish/vendor_completions.d/t.fish +install -m 644 -D completions/zsh/_t build/share/zsh/site-functions/_t + # compress the tar file -tar -cvzf tiempo-${CI_COMMIT_TAG:1}-x86_64.tar.gz build/ +tar -cvzf tiempo-${CI_COMMIT_TAG}-x86_64.tar.gz build/ # makes the debian archive ./scripts/debpackage.sh # computes the sums -sha256sum tiempo-${CI_COMMIT_TAG:1}-x86_64.tar.gz > tiempo-${CI_COMMIT_TAG:1}-x86_64.tar.gz.sum -sha256sum debian-package/tiempo_${CI_COMMIT_TAG:1}_amd64.deb > tiempo_${CI_COMMIT_TAG:1}_amd64.deb.sum +sha256sum tiempo-${CI_COMMIT_TAG}-x86_64.tar.gz > tiempo-${CI_COMMIT_TAG}-x86_64.tar.gz.sum +sha256sum debian-package/tiempo_${CI_COMMIT_TAG}_amd64.deb > tiempo_${CI_COMMIT_TAG}_amd64.deb.sum mkdir -p artifacts -mv tiempo-${CI_COMMIT_TAG:1}-x86_64.tar.gz artifacts/ -mv debian-package/tiempo_${CI_COMMIT_TAG:1}_amd64.deb artifacts/ -mv tiempo-${CI_COMMIT_TAG:1}-x86_64.tar.gz.sum artifacts/ -mv tiempo_${CI_COMMIT_TAG:1}_amd64.deb.sum artifacts/ +mv tiempo-${CI_COMMIT_TAG}-x86_64.tar.gz artifacts/ +mv debian-package/tiempo_${CI_COMMIT_TAG}_amd64.deb artifacts/ +mv tiempo-${CI_COMMIT_TAG}-x86_64.tar.gz.sum artifacts/ +mv tiempo_${CI_COMMIT_TAG}_amd64.deb.sum artifacts/ diff --git a/scripts/debpackage.sh b/scripts/debpackage.sh index d3f1648..6be14ad 100755 --- a/scripts/debpackage.sh +++ b/scripts/debpackage.sh @@ -20,7 +20,6 @@ DPKG_DIR="${DPKG_STAGING}/dpkg" PROJECT_MANTAINER="Abraham Toriz Cruz" PROJECT_HOMEPAGE="https://gitlab.com/categulario/tiempo-rs" PROJECT_NAME=tiempo -PROJECT_VERSION=${CI_COMMIT_TAG:1} PROJECT_BINARY=t PROJECT_DESCRIPTION="A command line time tracking application" @@ -28,9 +27,9 @@ mkdir -p "${DPKG_DIR}" DPKG_BASENAME=${PROJECT_NAME} DPKG_CONFLICTS= -DPKG_VERSION=${PROJECT_VERSION} +DPKG_VERSION=${CI_COMMIT_TAG:1} DPKG_ARCH=amd64 -DPKG_NAME="${DPKG_BASENAME}_${DPKG_VERSION}_${DPKG_ARCH}.deb" +DPKG_NAME="${DPKG_BASENAME}_${CI_COMMIT_TAG}_${DPKG_ARCH}.deb" DPKG_DEPENDS= DPKG_SECTION=utils diff --git a/scripts/release-aur-bin.sh b/scripts/release-aur-bin.sh index 444eab1..f32a5df 100755 --- a/scripts/release-aur-bin.sh +++ b/scripts/release-aur-bin.sh @@ -1,19 +1,15 @@ #!/bin/bash +set -e + # some useful variables VERSION=${CI_COMMIT_TAG:1} PROJECT_NAME=tiempo PROJECT_BINARY=t -ARCHIVENAME=$PROJECT_NAME-$VERSION-x86_64.tar.gz - -# clone the repo -git clone $BIN_REPO_URL $PROJECT_NAME-bin - -# enter it -cd $PROJECT_NAME-bin +ARCHIVENAME=$PROJECT_NAME-$CI_COMMIT_TAG-x86_64.tar.gz # get the sum from the artifacts -SUM=( `cat ../artifacts/$ARCHIVENAME.sum` ) +SUM=( `cat artifacts/$ARCHIVENAME.sum` ) # Generate the PKGBUILD echo "# Maintainer: Abraham Toriz @@ -28,7 +24,7 @@ depends=() optdepends=('sqlite: for manually editing the database') provides=('$PROJECT_NAME') conflicts=('$PROJECT_NAME') -source=(\"https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/packages/generic/v$VERSION/v$VERSION/$PROJECT_NAME-\${pkgver}-x86_64.tar.gz\") +source=(\"https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/packages/generic/$CI_COMMIT_TAG/$CI_COMMIT_TAG/$PROJECT_NAME-\${pkgver}-x86_64.tar.gz\") sha256sums=('$SUM') package() { @@ -46,6 +42,3 @@ package() { " | tee PKGBUILD > /dev/null makepkg --printsrcinfo > .SRCINFO -git add . -git commit -m "Release version $VERSION" -git push diff --git a/scripts/release-aur-git.sh b/scripts/release-aur-git.sh index 6d0e0e0..a2af8a2 100755 --- a/scripts/release-aur-git.sh +++ b/scripts/release-aur-git.sh @@ -5,12 +5,6 @@ VERSION=${CI_COMMIT_TAG:1} PROJECT_NAME=tiempo PROJECT_BINARY=t -# clone the repo -git clone $GIT_REPO_URL $PROJECT_NAME-git - -# enter it -cd $PROJECT_NAME-git - echo "# Maintainer: Abraham Toriz pkgname=$PROJECT_NAME-git pkgver=$VERSION @@ -55,6 +49,3 @@ package() { }" | tee PKGBUILD > /dev/null makepkg --printsrcinfo > .SRCINFO -git add . -git commit -m "Release version $VERSION" -git push