forked from guacsec/trustify-da-javascript-client
-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (100 loc) · 3.93 KB
/
Copy pathrelease.yml
File metadata and controls
113 lines (100 loc) · 3.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# yaml-language-server: $schema=https://www.schemastore.org/github-workflow.json
---
name: Release
on:
workflow_dispatch:
inputs:
version_type:
description: 'Type of version bump'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
permissions:
contents: write
pull-requests: write
jobs:
create-release:
runs-on: ubuntu-latest
name: Create release
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install node 24
uses: actions/setup-node@v5
with:
node-version: 24
cache: npm
- name: Configure git
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- name: Get previous released annotated tag
id: last-release
run: |
# Get the latest tag that doesn't have -ea suffix (handles both -ea. and -ea- formats)
TAG=$(git tag -l --sort=-version:refname | grep -vE -- '-ea[.-]' | head -n 1)
if [ -z "$TAG" ]; then
# If no release tag exists, use the base version from package.json
BASE_VERSION=$(node -p "require('./package.json').version" | sed -E 's/-ea[.-][0-9]+$//')
echo "base-tag=$BASE_VERSION" >> "$GITHUB_OUTPUT"
echo "full-tag=$BASE_VERSION" >> "$GITHUB_OUTPUT"
else
echo "base-tag=$TAG" >> "$GITHUB_OUTPUT"
echo "full-tag=$TAG" >> "$GITHUB_OUTPUT"
fi
- name: Get first tag in current development iteration
id: fetch-tag
run: |
BASE_TAG="${{ steps.last-release.outputs.base-tag }}"
# Find the oldest EA tag for this base version (handles both -ea. and -ea- formats)
OLDEST_EA_TAG=$(git tag -l --sort=creatordate | grep -E "^${BASE_TAG}-ea[.-]" | head -n 1)
if [ -n "$OLDEST_EA_TAG" ]; then
echo "oldest-tag=$OLDEST_EA_TAG" >> "$GITHUB_OUTPUT"
else
echo "oldest-tag=$BASE_TAG" >> "$GITHUB_OUTPUT"
fi
- name: Update package with new version
id: bump
run: |
# Get base version (remove -ea suffix if present, handles both -ea. and -ea- formats)
BASE_VERSION=$(node -p "require('./package.json').version" | sed -E 's/-ea[.-][0-9]+$//')
# Bump the version
NEW_VERSION=$(npm version ${{ inputs.version_type }} --no-git-tag-version | sed 's/v//')
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
- name: Install project modules
run: npm ci
- name: Create release branch
run: |
BRANCH="release/v${{ steps.bump.outputs.version }}"
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
git checkout -b "$BRANCH"
git add package.json
git add package-lock.json
git commit -m "build: release ${{ steps.bump.outputs.version }} [skip ci]"
git push origin "$BRANCH"
- name: Create GitHub release tag
uses: softprops/action-gh-release@v1
with:
name: "Release ${{ steps.bump.outputs.version }}"
tag_name: "v${{ steps.bump.outputs.version }}"
target_commitish: "release/v${{ steps.bump.outputs.version }}"
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Pull Request for release + next version
run: |
gh pr create \
--title "build: release ${{ steps.bump.outputs.version }}" \
--body "build: release ${{ steps.bump.outputs.version }}" \
--base main \
--head "release/v${{ steps.bump.outputs.version }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}