build-it #652
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
# This is a basic workflow to help you get started with Actions | |
name: build-it | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow on push or pull request events but only for the main branch | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
schedule: | |
- cron: 0 0 * * * | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "build" | |
build: | |
# The type of runner that the job will run on | |
runs-on: windows-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v2 | |
with: | |
repository: microsoft/winget-cli | |
- name: Write a release note! | |
run: '"This is a automated build of winget, from commit [$(git rev-parse HEAD)](https://github.com/microsoft/winget-cli/tree/$(git rev-parse HEAD)). Unzip wingetdev.zip to use it!" > release.txt' | |
- name: Restore it! | |
shell: cmd | |
run: | | |
"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 && msbuild -t:restore -m -p:RestorePackagesConfig=true -p:Configuration=Release src\AppInstallerCLI.sln | |
- name: Build it! | |
shell: cmd | |
run: | | |
"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 && msbuild -m -p:Configuration=Release -p:Platform=x64 src\AppInstallerCLI.sln | |
- name: Make that archive! | |
run: | | |
cp src\x64\Release\WindowsPackageManager\WindowsPackageManager.dll src\x64\Release\AppInstallerCLI\WindowsPackageManager.dll | |
mv src\x64\Release\AppInstallerCLI\winget.exe src\x64\Release\AppInstallerCLI\wingetdev.exe | |
Compress-Archive src\x64\Release\AppInstallerCLI\ .\wingetdev.zip | |
- name: Delete that old release! | |
uses: actions/github-script@v4 | |
continue-on-error: true | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const { owner, repo } = context.repo | |
const { data: { id } } = await github.repos.getLatestRelease({ owner, repo }) | |
await github.repos.deleteRelease({ owner, repo, release_id: id }) | |
- name: Create tag! | |
uses: actions/github-script@v5 | |
continue-on-error: true | |
with: | |
script: | | |
github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: `refs/tags/${context.runNumber}`, | |
sha: context.sha | |
}) | |
- name: Create that new release! | |
uses: softprops/action-gh-release@v1 | |
with: | |
body_path: release.txt | |
name: "wingetdev: ${{ github.run_number }}" | |
files: wingetdev.zip | |
tag_name: ${{ github.run_number }} | |
- name: Post it! | |
uses: actions/upload-artifact@v2.3.1 | |
with: | |
name: winget-cli | |
path: src/x64/Release/AppInstallerCLI/* | |
if-no-files-found: error | |