Skip to content

Commit

Permalink
ci(fix): add semantic release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
reey committed Jan 29, 2024
1 parent 919d763 commit 9e5ea06
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 8 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/main-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

on:
push:
# Sequence of patterns matched against refs/tags
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
branches:
- "main"
# push:
# # Sequence of patterns matched against refs/tags
# tags:
# - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
# branches:
# - "main"
pull_request:
branches: [main]

Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
- name: Upload Frontend Artifact
uses: actions/upload-artifact@v3
with:
name: cloud-http-proxy-ui-${{ env.C8Y_VERSION }}-${{ github.event.number }}-${{ github.run_id }}
name: cloud-http-proxy-ui-${{ env.C8Y_VERSION }}-${{ github.sha }}
if-no-files-found: error
retention-days: 5
path: frontend/dist/
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/semantic-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Semantic-Release
on:
push:
branches:
- main

env:
NODE_VERSION: ${{ '18' }}

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

jobs:
release:
name: Set release tag
runs-on: ubuntu-latest
timeout-minutes: 15
outputs:
initial-version: ${{ steps.save-initial-version.outputs.version }}
version: ${{ steps.save-version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Save initial Version
id: save-initial-version
run: echo "version=$(cat frontend/package.json | jq '.version' | xargs)" >> $GITHUB_OUTPUT

- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install Dependencies
run: |
npm i -g @semantic-release/changelog@^6.0.3 @semantic-release/exec@^6.0.3 @semantic-release/git@^10.0.1 semantic-release@^20.1.0
- name: Release
env:
GITHUB_TOKEN: ${{ github.token }}
GH_TOKEN: ${{ github.token }}
GITHUB_URL: ${{ github.server_url }}
HUSKY: 0
run: semantic-release

- name: Save Version
id: save-version
run: echo "version=$(cat frontend/package.json | jq '.version' | xargs)" >> $GITHUB_OUTPUT
74 changes: 74 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"branches": ["main"],
"tagFormat": "v${version}",
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "angular",
"releaseRules": [
{ "type": "test", "scope": "fix", "release": "patch" },
{ "type": "ci", "scope": "fix", "release": "patch" }
]
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "angular"
}
],
"@semantic-release/changelog",
[
"@semantic-release/npm",
{
"npmPublish": false,
"pkgRoot": "frontend"
}
],
[
"@semantic-release/npm",
{
"npmPublish": false,
"pkgRoot": "backend"
}
],
[
"@semantic-release/exec",
{
"prepareCmd": "cat backend/cumulocity.json | jq --arg version \"${nextRelease.version}\" '.version = $version' > backend/.tmp && mv backend/.tmp backend/cumulocity.json"
}
],
[
"@semantic-release/git",
{
"assets": [
"CHANGELOG.md",
"**/package.json",
"**/package-lock.json",
"**/cumulocity.json"
],
"message": "ci(release): ${nextRelease.version}\n\n${nextRelease.notes}"
}
],
[
"@semantic-release/exec",
{
"prepareCmd": "cd backend && npm run build:release"
}
],
[
"@semantic-release/exec",
{
"prepareCmd": "cd frontend && npm ci && npm run build:release"
}
],
[
"@semantic-release/github",
{
"assets": ["cloud-http-proxy-ui.zip", "cloud-http-proxy.zip"]
}
]
],
"preset": "angular"
}
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build:release": "ng build && zip ../cloud-http-proxy-ui ./dist",
"build:release": "ng build && cd dist && zip -r -q ../../cloud-http-proxy-ui *",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
Expand Down

0 comments on commit 9e5ea06

Please sign in to comment.