ci(release): automate castopod versioned releases using semantic-release

closes #38
This commit is contained in:
Yassine Doghri 2020-10-16 15:17:08 +00:00
parent 50e32ff756
commit 6c36888a21
7 changed files with 6064 additions and 517 deletions

6
.gitignore vendored
View File

@ -152,5 +152,7 @@ mariadb
phpmyadmin
sessions
# Castopod bundle
bundle/
# Castopod bundle & packages
castopod/
castopod-*.zip
castopod-*.tar.gz

View File

@ -2,6 +2,7 @@ image: php:7.2-fpm
stages:
- bundle
- release
cache:
paths:
@ -34,11 +35,12 @@ before_script:
- php composer.phar install --no-dev --ignore-platform-reqs
- npm install
# build all UI assets
- npm run build
bundle_app:
stage: bundle
script:
# build all assets for views
- npm run build
# download GeoLite2-City archive and extract it to writable/uploads
- wget -c "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=$MAXMIND_LICENCE_KEY&suffix=tar.gz" -O - | tar -xz -C ./writable/uploads/
@ -46,8 +48,32 @@ bundle_app:
- mv ./writable/uploads/GeoLite2-City* ./writable/uploads/GeoLite2-City
# create bundle folder: uses .rsync-filter (-F) file to copy only needed files
- rsync -avF --progress . ./bundle
- rsync -aF --progress . ./castopod
artifacts:
name: "castopod-${CI_COMMIT_REF_SLUG}_${CI_COMMIT_SHORT_SHA}"
paths:
- bundle
- castopod
except:
- main
- beta
- alpha
release_app:
stage: release
script:
# install required packages for prepare-release.sh script
- apt-get install jq -y
- apt-get install zip -y
# make prepare-release.sh executable
- chmod +x ./prepare-release.sh
# run semantic-release script (configured in `.releaserc.json` file)
- npm run release
# IMPORTANT: delete local git tags after release to prevent eventual script failure (ie. tag already exists)
- git tag | xargs git tag -d
only:
- main
- alpha
- beta

46
.releaserc.json Normal file
View File

@ -0,0 +1,46 @@
{
"branches": [
"main",
{ "name": "alpha", "prerelease": true },
{ "name": "beta", "prerelease": true }
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
[
"@semantic-release/exec",
{
"prepareCmd": "./prepare-release.sh ${nextRelease.version}"
}
],
"@semantic-release/npm",
[
"@semantic-release/git",
{
"assets": [
"composer.json",
"package.json",
"package-lock.json",
"CHANGELOG.md"
]
}
],
[
"@semantic-release/gitlab",
{
"gitlabUrl": "https://code.podlibre.org/",
"assets": [
{
"path": "castopod-*.zip",
"label": "Castopod Package (zip)"
},
{
"path": "castopod-*.tar.gz",
"label": "Castopod Package (tar.gz)"
}
]
}
]
]
}

View File

@ -1,5 +1,6 @@
{
"name": "podlibre/castopod",
"version": "0.0.0-dev",
"type": "project",
"description": "Castopod is an open-source hosting platform made for podcasters who want engage and interact with their audience.",
"homepage": "https://castopod.org",

6448
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,8 @@
"lint:css": "stylelint \"app/Views/_assets/**/*.css\"",
"prettier:fix": "prettier --write --ignore-path .gitignore .",
"typecheck": "tsc",
"commit": "git-cz"
"commit": "git-cz",
"release": "semantic-release"
},
"dependencies": {
"@amcharts/amcharts4": "^4.10.7",
@ -34,10 +35,10 @@
"prosemirror-view": "^1.16.0"
},
"devDependencies": {
"@babel/core": "^7.11.6",
"@babel/plugin-proposal-class-properties": "^7.10.4",
"@babel/preset-env": "^7.11.5",
"@babel/preset-typescript": "^7.10.4",
"@babel/core": "^7.12.1",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/preset-env": "^7.12.1",
"@babel/preset-typescript": "^7.12.1",
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@prettier/plugin-php": "^0.15.0",
@ -46,34 +47,39 @@
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-multi-entry": "^4.0.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/exec": "^5.0.0",
"@semantic-release/git": "^9.0.0",
"@semantic-release/gitlab": "^6.0.5",
"@tailwindcss/custom-forms": "^0.2.1",
"@tailwindcss/typography": "^0.2.0",
"@types/prosemirror-markdown": "^1.0.3",
"@types/prosemirror-view": "^1.16.0",
"@types/prosemirror-view": "^1.16.1",
"@typescript-eslint/eslint-plugin": "^4.4.1",
"@typescript-eslint/parser": "^4.4.1",
"cross-env": "^7.0.2",
"cssnano": "^4.1.10",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^7.11.0",
"eslint-config-prettier": "^6.12.0",
"eslint-config-prettier": "^6.13.0",
"eslint-plugin-prettier": "^3.1.4",
"husky": "^4.3.0",
"lint-staged": "^10.4.0",
"lint-staged": "^10.4.1",
"postcss-cli": "^8.1.0",
"postcss-import": "^12.0.1",
"postcss-preset-env": "^6.7.0",
"prettier": "2.1.2",
"prettier-plugin-organize-imports": "^1.1.1",
"rollup": "^2.30.0",
"rollup": "^2.31.0",
"rollup-plugin-multi-input": "^1.1.1",
"rollup-plugin-node-polyfills": "^0.2.1",
"rollup-plugin-postcss": "^3.1.8",
"rollup-plugin-terser": "^7.0.2",
"semantic-release": "^17.2.1",
"stylelint": "^13.7.2",
"stylelint-config-standard": "^20.0.0",
"svgo": "^1.3.2",
"tailwindcss": "^1.9.1",
"tailwindcss": "^1.9.2",
"typescript": "^4.0.3"
},
"husky": {

20
prepare-release.sh Normal file
View File

@ -0,0 +1,20 @@
#!/bin/bash
VERSION=$1
COMPOSER_VERSION=$(echo "$VERSION" | perl -pe 's/(?<=[alpha|beta])\.//g')
# replace composer.json version using jq
echo "$( jq '.version = "'$COMPOSER_VERSION'"' composer.json )" > composer.json
# download GeoLite2-City archive and extract it to writable/uploads
wget -c "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=v3PguJMcmZMb9Ld0&suffix=tar.gz" -O - | tar -xz -C ./writable/uploads/
# rename extracted archives' folders
mv ./writable/uploads/GeoLite2-City* ./writable/uploads/GeoLite2-City
# create castopod folder bundle: uses .rsync-filter (-F) file to copy only needed files
rsync -aF --progress . ./castopod
# create zip and tar.gz packages for release upload
zip -r castopod-$VERSION.zip castopod
tar -zcvf castopod-$VERSION.tar.gz castopod