Skip to content

Commit 5c25a13

Browse files
committed
new module githubactions flow
1 parent 259e3ef commit 5c25a13

File tree

6 files changed

+229
-155
lines changed

6 files changed

+229
-155
lines changed

.github/workflows/ci.yml

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

.github/workflows/gh-release.yml

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

.github/workflows/pr.yml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,24 @@ on:
66
- "main"
77
- "master"
88
- "development"
9+
- "releases/v*"
910
pull_request:
1011
branches:
12+
- "releases/v*"
1113
- development
1214

1315
jobs:
1416
tests:
1517
uses: ./.github/workflows/tests.yml
16-
secrets:
17-
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
18+
secrets: inherit
1819

19-
# Format PR
20-
format:
21-
name: Format
20+
formatCheck:
21+
name: Checks Source Code Formatting
2222
runs-on: ubuntu-20.04
2323
steps:
2424
- name: Checkout Repository
25-
uses: actions/checkout@v3.2.0
25+
uses: actions/checkout@v3
2626

2727
- uses: Ortus-Solutions/[email protected]
2828
with:
29-
cmd: run-script format
30-
31-
- name: Commit Format Changes
32-
uses: stefanzweifel/git-auto-commit-action@v4
33-
with:
34-
commit_message: Apply cfformat changes
29+
cmd: run-script format:check

.github/workflows/release.yml

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
name: Build a Release
2+
3+
on:
4+
# If you push to master|main this will trigger a stable release
5+
push:
6+
branches:
7+
- master
8+
- main
9+
10+
# Reusable workflow : Usually called by a `snapshot` workflow
11+
workflow_call:
12+
inputs:
13+
snapshot:
14+
description: 'Is this a snapshot build?'
15+
required: false
16+
default: false
17+
type: boolean
18+
19+
env:
20+
MODULE_ID: cbsecurity
21+
SNAPSHOT: ${{ inputs.snapshot || false }}
22+
23+
jobs:
24+
##########################################################################################
25+
# Build & Publish
26+
##########################################################################################
27+
build:
28+
name: Build & Publish
29+
runs-on: ubuntu-20.04
30+
steps:
31+
- name: Checkout Repository
32+
uses: actions/checkout@v3
33+
34+
- name: Setup CommandBox
35+
uses: Ortus-Solutions/[email protected]
36+
with:
37+
forgeboxAPIKey: ${{ secrets.FORGEBOX_TOKEN }}
38+
39+
- name: "Setup Environment Variables For Build Process"
40+
id: current_version
41+
run: |
42+
echo "VERSION=`cat box.json | jq '.version' -r`" >> $GITHUB_ENV
43+
44+
# master or snapshot
45+
echo "Github Ref is $GITHUB_REF"
46+
echo "BRANCH=master" >> $GITHUB_ENV
47+
if [ $GITHUB_REF == 'refs/heads/development' ]
48+
then
49+
echo "BRANCH=development" >> $GITHUB_ENV
50+
fi
51+
52+
- name: Update changelog [unreleased] with latest version
53+
uses: thomaseizinger/[email protected]
54+
if: env.SNAPSHOT == 'false'
55+
with:
56+
changelogPath: ./changelog.md
57+
tag: v${{ env.VERSION }}
58+
59+
- name: Build ${{ env.MODULE_ID }}
60+
run: |
61+
box install commandbox-docbox
62+
box task run taskfile=build/Build target=run :version=${{ env.VERSION }} :projectName=${{ env.MODULE_ID }} :buildID=${{ github.run_number }} :branch=${{ env.BRANCH }}
63+
64+
- name: Commit Changelog To Master
65+
uses: EndBug/[email protected]
66+
if: env.SNAPSHOT == 'false'
67+
with:
68+
author_name: Github Actions
69+
author_email: [email protected]
70+
message: 'Finalized changelog for v${{ env.VERSION }}'
71+
add: changelog.md
72+
73+
- name: Tag Version
74+
uses: rickstaa/[email protected]
75+
if: env.SNAPSHOT == 'false'
76+
with:
77+
tag: "v${{ env.VERSION }}"
78+
force_push_tag: true
79+
message: "Latest Release v${{ env.VERSION }}"
80+
81+
- name: Upload Build Artifacts
82+
if: success()
83+
uses: actions/upload-artifact@v3
84+
with:
85+
name: ${{ env.MODULE_ID }}
86+
path: |
87+
.artifacts/**/*
88+
changelog.md
89+
90+
- name: Publish To ForgeBox
91+
run: |
92+
cd .tmp/${{ env.MODULE_ID }} && box forgebox publish --force
93+
94+
- name: Create Github Release
95+
uses: taiki-e/[email protected]
96+
continue-on-error: true
97+
if: env.SNAPSHOT == 'false'
98+
with:
99+
title: ${{ env.VERSION }}
100+
changelog: changelog.md
101+
token: ${{ secrets.GITHUB_TOKEN }}
102+
ref: refs/tags/v${{ env.VERSION }}
103+
104+
##########################################################################################
105+
# Prep Next Release
106+
##########################################################################################
107+
prep_next_release:
108+
name: Prep Next Release
109+
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
110+
runs-on: ubuntu-20.04
111+
needs: [ build ]
112+
steps:
113+
# Checkout development
114+
- name: Checkout Repository
115+
uses: actions/checkout@v3
116+
with:
117+
ref: development
118+
119+
- name: Setup CommandBox
120+
uses: Ortus-Solutions/[email protected]
121+
with:
122+
forgeboxAPIKey: ${{ secrets.FORGEBOX_TOKEN }}
123+
124+
- name: Download build artifacts
125+
uses: actions/download-artifact@v2
126+
with:
127+
name: ${{ env.MODULE_ID }}
128+
path: .tmp
129+
130+
# Copy the changelog to the development branch
131+
- name: Copy Changelog
132+
run: |
133+
cp .tmp/changelog.md changelog.md
134+
135+
# Bump to next version
136+
- name: Bump Version
137+
run: |
138+
box bump --minor --!TagVersion
139+
140+
# Commit it back to development
141+
- name: Commit Version Bump
142+
uses: EndBug/[email protected]
143+
with:
144+
author_name: Github Actions
145+
author_email: [email protected]
146+
message: 'Version bump'
147+
add: |
148+
box.json
149+
changelog.md

.github/workflows/snapshot.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Build Snapshot
2+
3+
on:
4+
push:
5+
branches:
6+
- 'development'
7+
8+
jobs:
9+
##########################################################################################
10+
# Module Tests
11+
##########################################################################################
12+
tests:
13+
secrets: inherit
14+
uses: ./.github/workflows/tests.yml
15+
16+
##########################################################################################
17+
# Format Source Code
18+
##########################################################################################
19+
format:
20+
name: Code Auto-Formatting
21+
runs-on: ubuntu-20.04
22+
steps:
23+
- uses: actions/checkout@v3
24+
25+
- name: Auto-format
26+
uses: Ortus-Solutions/[email protected]
27+
with:
28+
cmd: run-script format
29+
30+
- name: Commit Format Changes
31+
uses: stefanzweifel/git-auto-commit-action@v4
32+
with:
33+
commit_message: Apply cfformat changes
34+
35+
##########################################################################################
36+
# Release it
37+
##########################################################################################
38+
release:
39+
uses: ./.github/workflows/release.yml
40+
needs: [ tests, format ]
41+
secrets: inherit
42+
with:
43+
snapshot: true

0 commit comments

Comments
 (0)