Skip to content

Commit

Permalink
ci(github): configure workflows with pre-release (#999)
Browse files Browse the repository at this point in the history
  • Loading branch information
ialejandro committed Oct 25, 2024
1 parent 23cb79c commit d0a3a95
Show file tree
Hide file tree
Showing 12 changed files with 173 additions and 1,174 deletions.
84 changes: 55 additions & 29 deletions .github/workflows/releases-create.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# TODO: refactor workflow when all components will migrate to
# each repository or move on same folder
#

name: "[Releases] Create"

env:
COMPONENTS: "app,backup,cleaner,drone-authorizer,gitea-oauth2-setup,mlflow,project-operator,repo-cloner,user-tools-operator,vscode"

on:
workflow_dispatch:
inputs:
Expand All @@ -9,7 +16,7 @@ on:
type: choice
options:
- all
- kdl-app
- app
- backup
- cleaner
- drone-authorizer
Expand All @@ -19,34 +26,47 @@ on:
- repo-cloner
- user-tools-operator
- vscode
pre_release:
description: 'Create pre-release?'
required: false
type: boolean

push:
branches:
- 'release/*'

jobs:
validate-conditions:
manual-create-tag-release:
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch'
steps:
- name: Validate release conditions
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-tags: true
persist-credentials: false

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ vars.NODE_VERSION }}

- name: Install NPM dependencies and create release
run: |
if [[ "${{ github.event.inputs.pre_release }}" == "true" && ! "${{ github.ref }}" =~ ^refs/heads/release/ ]]; then
echo "Pre-release can only be created from branches matching 'release/*'."
exit 1
elif [[ "${{ github.event.inputs.pre_release }}" == "false" && "${{ github.ref_name }}" != "main" ]]; then
echo "Regular releases can only be created from the 'main' branch."
exit 1
if [[ "${{ github.event.inputs.component }}" == "all" || -z "${{ github.event.inputs.component }}" ]]; then
for COMPONENT in $(echo $COMPONENTS | tr ',' ' '); do
echo "Releasing component: $COMPONENT"
cd $COMPONENT && npm install && npx semantic-release
done
else
echo "Conditions are met for the release."
echo "Releasing component: ${{ github.event.inputs.component }}"
cd ${{ github.event.inputs.component }} && npm install && npx semantic-release
fi
env:
GITHUB_TOKEN: ${{ secrets.PAT }}

create-tag-release:
prerelease-create-tag-release:
runs-on: ubuntu-latest
needs: validate-conditions
if: |
startsWith(github.ref, 'refs/heads/release/') &&
github.event_name != 'workflow_dispatch'
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -55,24 +75,30 @@ jobs:
fetch-tags: true
persist-credentials: false

- name: Detect changed components
id: detect-components
run: |
COMPONENTS_LIST=""
for COMPONENT in $(echo $COMPONENTS | tr ',' ' '); do
if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q "^$COMPONENT/"; then
COMPONENTS_LIST="$COMPONENTS_LIST $COMPONENT"
fi
done
COMPONENTS_LIST=$(echo $COMPONENTS_LIST | xargs)
echo "Detected components: $COMPONENTS_LIST"
echo "CHANGED_COMPONENTS=$COMPONENTS_LIST" >> $GITHUB_ENV
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ vars.NODE_VERSION }}
cache: 'npm'

- name: Install NPM dependencies
- name: Create release for changed component
run: |
npm install
- name: Install NPM dependencies and create release
run: |
if [[ "${{ github.event.inputs.component }}" == "all" || -z "${{ github.event.inputs.component }}" ]]; then
echo "No specific component selected or 'all' selected. Releasing all components."
yarn workspaces run semantic-release
else
echo "Releasing component: ${{ github.event.inputs.component }}"
yarn workspace ${{ github.event.inputs.component }} run semantic-release
fi
for COMPONENT in $(echo ${{ env.CHANGED_COMPONENTS }} | tr ',' ' '); do
echo "Releasing component: $COMPONENT"
cd $COMPONENT && npm install && npx semantic-release
done
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
3 changes: 2 additions & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"main",
{
"name": "release/*",
"prerelease": "rc"
"prerelease": "rc",
"channel": "default"
}
],
"plugins": [
Expand Down
3 changes: 2 additions & 1 deletion backup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"main",
{
"name": "release/*",
"prerelease": "rc"
"prerelease": "rc",
"channel": "default"
}
],
"plugins": [
Expand Down
3 changes: 2 additions & 1 deletion cleaner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"main",
{
"name": "release/*",
"prerelease": "rc"
"prerelease": "rc",
"channel": "default"
}
],
"plugins": [
Expand Down
33 changes: 25 additions & 8 deletions drone-authorizer/package.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,44 @@
{
"name": "drone-authorizer",
"description": "This application uses a headless browser to automate the oAuth2 authorization with Drone process.",
"license": "MIT",
"author": "Konstellation",
"version": "1.0.0",
"author": "Konstellation",
"license": "MIT",
"description": "This application uses a headless browser to automate the oAuth2 authorization with Drone process.",
"main": "index.js",
"dependencies": {
"puppeteer": "^19.4.0"
},
"devDependencies": {},
"main": "index.js",
"devDependencies": {
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^13.0.0",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^11.0.0",
"@semantic-release/release-notes-generator": "^14.0.1",
"semantic-release": "^24.1.3"
},
"release": {
"tagFormat": "drone-authorizer-v${version}",
"extends": "semantic-release-monorepo",
"branches": [
"main",
{
"name": "release/*",
"prerelease": "rc"
"name": "release/*",
"prerelease": "rc",
"channel": "default"
}
],
"extends": "semantic-release-monorepo",
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/git",
{
"assets": [
"**/package.json"
],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
],
[
"@semantic-release/github",
{
Expand Down
3 changes: 2 additions & 1 deletion gitea-oauth2-setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"main",
{
"name": "release/*",
"prerelease": "rc"
"prerelease": "rc",
"channel": "default"
}
],
"plugins": [
Expand Down
3 changes: 2 additions & 1 deletion mlflow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"main",
{
"name": "release/*",
"prerelease": "rc"
"prerelease": "rc",
"channel": "default"
}
],
"plugins": [
Expand Down
3 changes: 2 additions & 1 deletion project-operator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"main",
{
"name": "release/*",
"prerelease": "rc"
"prerelease": "rc",
"channel": "default"
}
],
"plugins": [
Expand Down
3 changes: 2 additions & 1 deletion repo-cloner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"main",
{
"name": "release/*",
"prerelease": "rc"
"prerelease": "rc",
"channel": "default"
}
],
"plugins": [
Expand Down
3 changes: 2 additions & 1 deletion user-tools-operator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"main",
{
"name": "release/*",
"prerelease": "rc"
"prerelease": "rc",
"channel": "default"
}
],
"plugins": [
Expand Down
1 change: 0 additions & 1 deletion vscode/.force-release

This file was deleted.

Loading

0 comments on commit d0a3a95

Please sign in to comment.