upload-msi #321
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: Upload Windows MSI to Dolt Release | |
on: | |
repository_dispatch: | |
types: [ upload-msi ] | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'SemVer format dolt release tag, i.e. 0.24.5' | |
required: true | |
commitish: | |
description: 'the dolt commit used to build the msi. if provided, used instead of version number' | |
required: false | |
default: '' | |
jobs: | |
get-release-id: | |
name: Get Dolt Release Id | |
runs-on: ubuntu-22.04 | |
outputs: | |
release_id: ${{ steps.get_release.outputs.release_id }} | |
steps: | |
- name: Get Release | |
id: get_release | |
run: | | |
release_id="$RELEASE_ID" | |
if [ "$EVENT_TYPE" == "workflow_dispatch" ]; then | |
release_id=$(curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/dolthub/dolt/releases/tags/v${{ github.event.inputs.version }} | jq '.id') | |
fi | |
echo "::set-output name=release_id::$release_id" | |
env: | |
EVENT_TYPE: ${{ github.event_name }} | |
RELEASE_ID: ${{ github.event.client_payload.release_id }} | |
get-version: | |
name: Get Version | |
runs-on: ubuntu-22.04 | |
outputs: | |
version: ${{ steps.get_version.outputs.version }} | |
steps: | |
- name: Get version | |
id: get_version | |
run: | | |
version="" | |
if [ "${{ github.event_name }}" == "repository_dispatch" ] | |
then | |
version="${{ github.event.client_payload.tag }}" | |
else | |
version="${{ github.event.inputs.version }}" | |
fi | |
echo "::set-output name=version::$version" | |
build-release-binaries: | |
needs: get-version | |
name: Build Release Binaries | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
repository: dolthub/dolt | |
ref: ${{ github.event.inputs.commitish || format('v{0}', needs.get-version.outputs.version) }} | |
token: ${{ secrets.REPO_ACCESS_TOKEN }} | |
- name: Build Binaries | |
run: | | |
GO_BUILD_VERSION=1.21 go/utils/publishrelease/buildbinaries.sh | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: dolt-windows-amd64-latest | |
path: go/out/dolt-windows-amd64.zip | |
upload-windows-msi: | |
needs: [get-version, get-release-id, build-release-binaries] | |
name: Upload Windows MSI to Dolt Release | |
runs-on: windows-2019 | |
defaults: | |
run: | |
shell: powershell | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Build Windows MSI | |
run: | | |
mkdir archives | |
mkdir output | |
- uses: actions/download-artifact@v2 | |
with: | |
name: dolt-windows-amd64-latest | |
path: archives/dolt-windows-amd64.zip | |
- name: Run Process.bat | |
run: | | |
./process.bat | |
- name: Upload MSI to Dolt Release | |
uses: actions/github-script@v4 | |
with: | |
debug: true | |
github-token: ${{ secrets.REPO_ACCESS_TOKEN }} | |
script: | | |
const fs = require('fs'); | |
const path = require('path') | |
try { | |
const data = fs.readFileSync(path.join(process.env.WORKSPACE, "output", "dolt-windows-amd64.msi")) | |
const res = await github.repos.uploadReleaseAsset({ | |
owner: "dolthub", | |
repo: "dolt", | |
name: "dolt-windows-amd64.msi", | |
release_id: parseInt(process.env.RELEASE_ID, 10), | |
data, | |
}); | |
console.log("Successfully uploaded windows msi", res) | |
} catch (err) { | |
console.log("Error", err); | |
process.exit(1); | |
} | |
env: | |
WORKSPACE: ${{ github.workspace }} | |
RELEASE_ID: ${{ needs.get-release-id.outputs.release_id }} | |
bump-dolt-packages: | |
needs: [get-version, upload-windows-msi] | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Trigger Bump Winget | |
uses: peter-evans/repository-dispatch@v1 | |
with: | |
token: ${{ secrets.REPO_ACCESS_TOKEN }} | |
event-type: bump-winget | |
repository: dolthub/dolt | |
client-payload: '{"version": "${{ needs.get-version.outputs.version }}"}' | |
- name: Trigger Bump Chocolatey | |
uses: peter-evans/repository-dispatch@v1 | |
with: | |
token: ${{ secrets.REPO_ACCESS_TOKEN }} | |
event-type: bump-chocolatey | |
repository: dolthub/chocolatey-packages | |
client-payload: '{"version": "${{ needs.get-version.outputs.version }}"}' |