Skip to content

Commit fd77d84

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

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
@@ -144,7 +144,60 @@ jobs:
144144
if: ${{github.event_name == 'push' && github.ref == 'refs/heads/main'}}
145145
uses: remal-github-actions/read-nodejs-package-version@v1
146146

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

0 commit comments

Comments
 (0)