Skip to content

Commit 2df257c

Browse files
committed
chore: Adding release action
1 parent be25850 commit 2df257c

2 files changed

Lines changed: 117 additions & 27 deletions

File tree

.github/workflows/publish.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Create release # You may choose a different name
2+
run-name: ${{ inputs.releaseversion }} # Enumerates entries in the "workflow runs" view
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
releaseversion:
7+
description: 'Release version'
8+
required: true
9+
type: string
10+
default: "X.Y.Z"
11+
12+
jobs:
13+
release: # Arbitrarily chosen
14+
name: Release
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: write
18+
packages: write
19+
attestations: write
20+
id-token: write
21+
steps:
22+
23+
- uses: actions/create-github-app-token@v2
24+
id: app-token
25+
with:
26+
app-id: ${{ vars.CI_APP_ID }}
27+
private-key: ${{ secrets.CI_PRIVATE_KEY }}
28+
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
token: ${{ steps.app-token.outputs.token }}
34+
ref: ${{ github.head_ref }}
35+
36+
- name: Get GitHub App User ID
37+
id: get-user-id
38+
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
39+
env:
40+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
41+
42+
- name: Configure Git author
43+
run: |
44+
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
45+
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com>'
46+
47+
- name: Setup NodeJS
48+
uses: actions/setup-node@v4
49+
with:
50+
node-version: '22'
51+
registry-url: 'https://registry.npmjs.org'
52+
53+
- name: Package Application
54+
run: |
55+
npm run clean
56+
npm version --no-git-tag-version ${{ github.event.inputs.releaseversion }}
57+
npm run build
58+
59+
- name: Write version vars
60+
run: |
61+
BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
62+
BRANCH=${GITHUB_REF_NAME#v}
63+
APP_VERSION=$(cat package.json | grep version| head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g')
64+
echo Version: $APP_VERSION
65+
echo "VERSION=$APP_VERSION" >> $GITHUB_ENV
66+
echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV
67+
echo "BUILD_DATE=$BUILD_DATE" >> $GITHUB_ENV
68+
69+
- name: Conventional Changelog Action
70+
uses: TriPSs/conventional-changelog-action@v6
71+
with:
72+
input-file: CHANGELOG.md
73+
github-token: ${{ steps.app-token.outputs.token }}
74+
version-file: package.json
75+
pre-release: true
76+
skip-bump: true
77+
skip-tag: true
78+
skip-on-empty: true
79+
tag-prefix: 'v'
80+
81+
- name: Create Release on GH
82+
id: tag-and-release
83+
uses: avakar/tag-and-release@v1
84+
with:
85+
draft: true
86+
release_name: ${{ github.event.inputs.releaseversion }}
87+
tag_name: v${{ github.event.inputs.releaseversion }}
88+
env:
89+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
91+
- name: Build Container Image
92+
id: build-image
93+
uses: redhat-actions/buildah-build@v2
94+
with:
95+
image: continuoussecuritytooling/keycloak-reporting-cli
96+
tags: 'latest ${{ github.event.inputs.releaseversion }}'
97+
containerfiles: |
98+
./Dockerfile
99+
build-args: |
100+
BUILD_DATE=${{ env.BUILD_DATE }}
101+
APP_VERSION=${{ github.event.inputs.releaseversion }}
102+
103+
- name: Push To Docker Hub
104+
id: push-to-dockerhub-preview
105+
uses: redhat-actions/push-to-registry@v2
106+
with:
107+
image: ${{ steps.build-image.outputs.image }}
108+
tags: 'latest ${{ github.event.inputs.releaseversion }}'
109+
registry: registry.hub.docker.com
110+
username: continuoussecuritytooling
111+
password: ${{ secrets.DOCKER_HUB_TOKEN }}
112+
113+
- name: Publish npm package
114+
run: |
115+
npm publish
116+
env:
117+
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

0 commit comments

Comments
 (0)