Skip to content

Commit

Permalink
Automatic creation of releases from CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
oldnomad committed Oct 12, 2023
1 parent bfebdd3 commit 0fd86fb
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 8 deletions.
46 changes: 38 additions & 8 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ image: debian:bookworm-slim

stages:
- test
- deploy
- release

before_script:
- apt-get update -yqq
- apt-get install -yqq git make composer librsvg2-bin netpbm php-xdebug php-sqlite3 php-curl php-xml php-mbstring php-json php-zip php-intl
.prepare:
before_script:
- export DEBIAN_FRONTEND=noninteractive
- apt-get update -yqq
- apt-get install -yqq git make composer curl sed librsvg2-bin netpbm php-xdebug php-sqlite3 php-curl php-xml php-mbstring php-json php-zip php-intl

variables:
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${CI_COMMIT_TAG}"

test-job:
stage: test
extends: .prepare
script:
- composer update
- composer tests
Expand All @@ -22,17 +28,41 @@ test-job:
when: on_success
expire_in: 30 days

deploy-job:
stage: deploy
only:
- tags
build-job:
stage: release
extends: .prepare
rules:
- if: $CI_COMMIT_TAG =~ /^v[\d.]+/
script:
- composer update --no-dev
- ./generate-icon.sh
- make appstore
- ./generate-relinfo.sh
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file build/artifacts/appstore/calibre_opds.tar.gz "${PACKAGE_REGISTRY_URL}/calibre_opds.tar.gz"
artifacts:
paths:
- build/artifacts/appstore/calibre_opds.tar.gz
- build/relinfo.md
untracked: false
when: on_success
expire_in: 30 days

release-job:
stage: release
needs:
- job: build-job
artifacts: true
rules:
- if: $CI_COMMIT_TAG =~ /^v[\d.]+/
image: registry.gitlab.com/gitlab-org/release-cli:latest
script:
- echo "Running the release job"
release:
tag_name: $CI_COMMIT_TAG
description: ./build/relinfo.md
assets:
links:
- name: App tarball
url: "${PACKAGE_REGISTRY_URL}/calibre_opds.tar.gz"
link_type: package
10 changes: 10 additions & 0 deletions generate-relinfo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
#
# This script needs `sed`.
#
set -e

CUR_DIR=$(dirname "$0")

mkdir -p "$CUR_DIR/build"
sed -n '/^## /{p;:a;n;/^## /q;p;ba}' "$CUR_DIR/CHANGELOG.md" >"$CUR_DIR/build/relinfo.md"

0 comments on commit 0fd86fb

Please sign in to comment.