Skip to content

Don't hide update progress dialog just because update notification di… #166

Don't hide update progress dialog just because update notification di…

Don't hide update progress dialog just because update notification di… #166

Workflow file for this run

name: Package and Release
on:
push:
branches:
- master
jobs:
release:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2 # we need the last two commits to check if the version changed
- name: Get package version
id: check_versions
run: |
$previous_version = git show HEAD~1:release/app/package.json | Select-String -Pattern '"version":' | ForEach-Object { $_ -replace '.*?: "(.*)",', '$1' }
$current_version = git show HEAD:release/app/package.json | Select-String -Pattern '"version":' | ForEach-Object { $_ -replace '.*?: "(.*)",', '$1' }
"previous_version=$previous_version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
"current_version=$current_version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
if ($previous_version -ne $current_version) {
"version_changed=true" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
} else {
"version_changed=false" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
}
"Previous Version = $previous_version" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append
"Current Version = $current_version" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: 16
architecture: 'x64'
# GitHub dependencies don't work in GitHub Action workflows...
- name: Remove CascLib dependency
run: npm remove CascLib
- name: Install dependencies
run: npm install
- name: Build package
run: npm run package
- name: Delete release
uses: actions/github-script@v6
with:
script: |
const releaseName = "D2RMM ${{ steps.check_versions.outputs.current_version }}";
const releases = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo
});
const releaseToDelete = releases.data.find(release => release.name === releaseName);
if (releaseToDelete) {
await github.rest.repos.deleteRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: releaseToDelete.id
});
console.log(`Release ${releaseName} deleted successfully.`);
} else {
console.log(`Release ${releaseName} not found.`);
}
- name: Delete tag
uses: actions/github-script@v6
with:
script: |
const tagName = "v${{ steps.check_versions.outputs.current_version }}";
try {
await github.rest.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `tags/${tagName}`
});
console.log(`Tag ${tagName} deleted successfully.`);
} catch (e) {
if (e.message.includes('Reference does not exist')) {
console.log(`Tag ${tagName} not found.`);
} else {
console.log(`Tag ${tagName} not deleted.`, e);
}
}
- name: Create tag
uses: actions/github-script@v6
with:
script: |
const tagName = "v${{ steps.check_versions.outputs.current_version }}";
try {
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${tagName}`,
sha: context.sha
});
console.log(`Tag ${tagName} created successfully.`);
} catch (e) {
console.log(`Tag ${tagName} not created.`, e);
core.setFailed(e.message);
}
- name: Create release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: D2RMM ${{ steps.check_versions.outputs.current_version }}
tag: v${{ steps.check_versions.outputs.current_version }}
draft: false
prerelease: true
artifacts: release/build/D2RMM ${{ steps.check_versions.outputs.current_version }}.zip
artifactErrorsFailBuild: true
generateReleaseNotes: false
- name: Finalize pre-release
if: steps.check_versions.outputs.version_changed == 'true'
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: D2RMM ${{ steps.check_versions.outputs.previous_version }}
tag: v${{ steps.check_versions.outputs.previous_version }}
allowUpdates: true
preRelease: false
- name: Generate documentation
run: npm run docs
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs