Create new release #68
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create new release | |
on: | |
workflow_dispatch: | |
inputs: | |
new_version: | |
description: 'New version' | |
required: true | |
type: string | |
jobs: | |
set-new-version: | |
runs-on: ubuntu-latest | |
outputs: | |
commit_hash: ${{steps.commit_new_version.outputs.commit_hash}} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set new version format | |
run: | | |
if [[ "${{ inputs.new_version }}" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; | |
then | |
echo "New version looks okay"; | |
MAJOR="${BASH_REMATCH[1]}" | |
MINOR="${BASH_REMATCH[2]}" | |
PATCH="${BASH_REMATCH[3]}" | |
sed -r -i "s/\"version\": *\"[0-9]+\\.[0-9]+\\.[0-9]+\"/\"version\": \"$MAJOR.$MINOR.$PATCH\"/g" package.json | |
else | |
echo "Invalid version format"; | |
exit 1 | |
fi | |
- id: commit_new_version | |
uses: stefanzweifel/git-auto-commit-action@v5.0.0 | |
with: | |
commit_message: Updated version | |
push_options: '--force' | |
create-release: | |
runs-on: ubuntu-latest | |
needs: set-new-version | |
outputs: | |
upload_url: ${{steps.create-release.outputs.upload_url}} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: "${{needs.set-new-version.outputs.commit_hash}}" | |
fetch-depth: 0 | |
- id: create-release | |
uses: ncipollo/release-action@v1.14.0 | |
with: | |
bodyFile: ".github/release-body.md" | |
artifactErrorsFailBuild: true | |
updateOnlyUnreleased: true | |
allowUpdates: true | |
removeArtifacts: true | |
draft: true | |
tag: "v${{ inputs.new_version }}" | |
commit: "${{needs.set-new-version.outputs.commit_hash}}" | |
build: | |
strategy: | |
matrix: | |
os: [windows-latest, ubuntu-latest, macos-latest] | |
runs-on: ${{ matrix.os }} | |
needs: [set-new-version, create-release] | |
env: | |
GH_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: "${{needs.set-new-version.outputs.commit_hash}}" | |
fetch-depth: 0 | |
- name: Install Node.js | |
uses: actions/setup-node@v4.0.2 | |
with: | |
node-version-file: ./.nvmrc | |
- uses: pnpm/action-setup@v3 | |
id: install-pnpm | |
name: Install pnpm | |
with: | |
version: latest | |
run_install: false | |
- name: Install dependencies | |
run: | | |
pnpm config set node-linker hoisted --location project | |
pnpm install | |
- name: Fix PNPM to run build | |
shell: pwsh | |
run: | | |
$root_path = "${{steps.install-pnpm.outputs.bin_dest}}/../.pnpm/" | |
Get-ChildItem -Path $root_path -Recurse -Filter "pnpm.cjs" | ForEach-Object { | |
$pnpmcjs = $_.FullName | |
(Get-Content $pnpmcjs -Raw) -replace '#!/usr/bin/env node', '#!node' | Set-Content $pnpmcjs -NoNewline | |
} | |
if: ${{ matrix.os == 'windows-latest' }} | |
- name: Build | |
run: | | |
pnpm build | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: release-${{ matrix.os }} | |
path: | | |
dist/*.blockmap | |
dist/*.exe | |
dist/*.zip | |
dist/*.dmg | |
dist/*.AppImage | |
dist/latest.yml | |
dist/latest-*.yml | |
checksum: | |
runs-on: ubuntu-latest | |
needs: ['create-release', 'build'] | |
steps: | |
- name: Download release artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: release-* | |
path: release | |
merge-multiple: true | |
- name: Generate checksum | |
run: | | |
cd release | |
find . -type f -maxdepth 1 -exec sha256sum {} \; > ../checksum.txt | |
- name: Upload Release Asset | |
uses: shogo82148/actions-upload-release-asset@v1 | |
with: | |
upload_url: ${{ needs.create-release.outputs.upload_url }} | |
asset_path: checksum.txt |