Skip to content

Commit 380814c

Browse files
remalremal-github-actions
andauthored
Template repository changes: remal-github-actions/template-typescript (#1349)
Co-authored-by: remal-github-actions <77626445+remal-github-actions+sync-with-template@users.noreply.github.com>
1 parent eacaa0e commit 380814c

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

.github/sync-with-template.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ includes:
1717
- check-dependency-engines.*js
1818
- update-node-version-in-files.*js
1919
- tsconfig-generate-app.*js
20+
- .releaseignore
2021
excludes:
2122
- .github/workflows/*template*-cleanup.*
2223
- .github/*template*-cleanup/**

.github/workflows/build.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,60 @@ jobs:
138138
if: ${{github.event_name == 'push' && github.ref == 'refs/heads/main'}}
139139
uses: remal-github-actions/read-nodejs-package-version@v1
140140

141+
- name: Remove files listed in .releaseignore
142+
if: ${{github.event_name == 'push' && github.ref == 'refs/heads/main'}}
143+
id: releaseignore
144+
uses: actions/github-script@v8
145+
with:
146+
script: |
147+
const fs = require('fs')
148+
const path = require('path')
149+
150+
const cwdPath = path.resolve(process.cwd())
151+
152+
const releaseIgnorePath = '.releaseignore'
153+
const releaseIgnoreFullPath = path.resolve(cwdPath, releaseIgnorePath)
154+
if (!fs.existsSync(releaseIgnoreFullPath)) {
155+
core.info(`${releaseIgnorePath} file does not exist, skipping removal of files.`)
156+
core.setOutput('skipped', 'true')
157+
return
158+
}
159+
160+
let patternsToIgnore = fs.readFileSync(releaseIgnoreFullPath, 'utf-8')
161+
.split('\n')
162+
.map(line => line.replace(/#.*/, '').trim())
163+
.filter(line => line.length)
164+
.join('\n')
165+
if (!patternsToIgnore.length) {
166+
core.info(`${releaseIgnorePath} file does not have patterns, skipping removal of files.`)
167+
core.setOutput('skipped', 'true')
168+
return
169+
}
170+
171+
const gitDirPath = path.resolve(cwdPath, '.git')
172+
173+
const globber = await glob.create(patternsToIgnore)
174+
const files = await globber.glob()
175+
files
176+
.map(file => path.resolve(cwdPath, file))
177+
.filter(file => file != cwdPath)
178+
.filter(file => file != gitDirPath && !file.startsWith(gitDirPath + path.sep))
179+
.forEach(file => {
180+
core.debug(`Removing: ${file}`)
181+
fs.rmSync(file, { recursive: true, force: true })
182+
})
183+
184+
- name: Prepare release commit
185+
if: ${{github.event_name == 'push' && github.ref == 'refs/heads/main' && !steps.releaseignore.outputs.skipped}}
186+
run: |
187+
RELEASE_BRANCH="release/v${{steps.readVersion.outputs.majorVersion}}"
188+
git switch --force-create "$RELEASE_BRANCH"
189+
git add --all
190+
git commit -m "[skip-ci] Release v${{steps.readVersion.outputs.majorVersion}}" || true
191+
git push --force origin "$RELEASE_BRANCH"
192+
141193
- name: Create tag
194+
if: ${{github.event_name == 'push' && github.ref == 'refs/heads/main'}}
142195
uses: remal-github-actions/create-tag@v2
143196
with:
144197
tagName: 'v${{steps.readVersion.outputs.majorVersion}}'

0 commit comments

Comments
 (0)