Skip to content

Commit 3aacbd7

Browse files
chore: Added a release-workflow (#48)
* chore: Added a release-workflow * fixup! chore: Added a release-workflow
1 parent dc37a79 commit 3aacbd7

File tree

3 files changed

+144
-3
lines changed

3 files changed

+144
-3
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v4
13+
1314
- name: Use Node.js # will read version from .nvmrc
1415
uses: actions/setup-node@v4
1516
with:
1617
node-version-file: '.nvmrc'
17-
# install packages
18+
1819
- name: Install dependencies
1920
run: npm ci
20-
# run tests
21+
2122
- name: Test
2223
run: npm run test
23-
# build the package
24+
2425
- name: Build
2526
run: npm run build

.github/workflows/release.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Triggers on version tags like v1.0.0, v2.1.3, etc.
7+
8+
permissions:
9+
contents: write # Required for creating releases
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0 # Fetch full history for changelog generation
19+
20+
- name: Use Node.js # will read version from .nvmrc
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version-file: '.nvmrc'
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Run tests
29+
run: npm run test
30+
31+
- name: Build
32+
run: npm run build
33+
34+
- name: Extract version from tag
35+
id: version
36+
run: |
37+
# Remove 'v' prefix from tag to get version
38+
VERSION=${GITHUB_REF#refs/tags/v}
39+
echo "version=$VERSION" >> $GITHUB_OUTPUT
40+
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
41+
42+
- name: Generate changelog for GitHub Release
43+
id: changelog
44+
run: |
45+
# Get the previous tag
46+
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
47+
48+
# Generate changelog between tags
49+
if [ -n "$PREV_TAG" ]; then
50+
CHANGELOG=$(git log --pretty=format:"- %s (%h)" $PREV_TAG..HEAD)
51+
else
52+
CHANGELOG=$(git log --pretty=format:"- %s (%h)")
53+
fi
54+
55+
# Save changelog to output (handle multiline)
56+
echo "changelog<<EOF" >> $GITHUB_OUTPUT
57+
echo "$CHANGELOG" >> $GITHUB_OUTPUT
58+
echo "EOF" >> $GITHUB_OUTPUT
59+
60+
- name: Create GitHub Release
61+
env:
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
run: |
64+
# Create release body
65+
cat > release_body.md << 'EOF'
66+
## Changes in ${{ steps.version.outputs.tag }}
67+
68+
${{ steps.changelog.outputs.changelog }}
69+
70+
## Installation
71+
72+
```bash
73+
npm install @dynatrace-oss/dynatrace-mcp-server@${{ steps.version.outputs.version }}
74+
```
75+
EOF
76+
77+
# Create the release
78+
if [[ "${{ steps.version.outputs.version }}" == *"-"* ]]; then
79+
gh release create "${{ steps.version.outputs.tag }}" \
80+
--title "Release ${{ steps.version.outputs.tag }}" \
81+
--notes-file release_body.md \
82+
--prerelease
83+
else
84+
gh release create "${{ steps.version.outputs.tag }}" \
85+
--title "Release ${{ steps.version.outputs.tag }}" \
86+
--notes-file release_body.md
87+
fi

RELEASE.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Release Process
2+
3+
This repository uses automated GitHub workflows to prepare releases whenever a new tag is pushed.
4+
5+
## How it works
6+
7+
1. When you push a tag starting with `v` (e.g., `v1.0.0`, `v2.1.3`), the release workflow automatically triggers
8+
2. The workflow builds the project, runs tests, and creates a GitHub release with auto-generated release notes
9+
10+
**Note**: This workflow does (not yet) publish the release to npmjs.com.
11+
12+
## Creating a Release
13+
14+
### Manual tagging
15+
16+
```bash
17+
# Make sure you're on the main branch and have latest changes
18+
git checkout main
19+
git pull origin main
20+
21+
# Run tests and build locally (optional but recommended)
22+
npm test
23+
npm run build
24+
25+
# Create and push a tag
26+
git tag vx.y.z # Replace with your desired version
27+
git push origin vx.y.z
28+
```
29+
30+
After pushing the tag, the workflow will automatically:
31+
1. Run tests
32+
2. Build the project
33+
3. Generate release notes from commit history
34+
4. Create a GitHub release
35+
36+
### Creating Pre-releases
37+
38+
For beta or alpha releases:
39+
40+
```bash
41+
# Create a pre-release tag
42+
git tag vx.y.z-beta.1
43+
git push origin vx.y.z-beta.1
44+
```
45+
46+
Pre-releases will be automatically marked as such in the GitHub release.
47+
48+
## Release Notes
49+
50+
The workflow automatically generates technical release notes by collecting all commit messages between the current and previous tag. The release notes include:
51+
52+
- A list of changes with commit hashes
53+
- Proper pre-release marking for beta/alpha versions

0 commit comments

Comments
 (0)