PublishScriptSync #72
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: PublishScriptSync | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
jobs: | |
####################### sync version ####################### | |
sync_version: | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Python setup | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Install python dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install invoke | |
- name: Install GitHub CLI | |
run: | | |
choco install gh | |
- name: Authenticate GitHub CLI | |
run: | | |
echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token | |
- name: Sync version | |
run: invoke syncv | |
- name: Delete branch remotely version-sync-branch (if exists) | |
run: | | |
git fetch --prune | |
git branch -r | grep version-sync-branch && git push origin --delete version-sync-branch | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create new branch and commit version change | |
run: | | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
git checkout -b version-sync-branch | |
git commit -am "ACTION_BOT: Sync version for release" | |
git push --set-upstream origin version-sync-branch | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Close existing pull requests for version-sync-branch | |
run: | | |
gh pr list --state open --head version-sync-branch --json number --jq '.[].number' | ForEach-Object { gh pr close $_ } | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
shell: pwsh | |
- name: Create pull request | |
run: | | |
gh pr create --title "ACTION_BOT: Sync version for release" --body "Sync version for release" --base main --head version-sync-branch --label ACTION_BOT | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Approve pull request | |
run: | | |
$prId = gh pr list --head version-sync-branch --json id --jq '.[0].id' | |
gh api graphql -f query=' | |
mutation($prId: ID!) { | |
addPullRequestReview(input: {pullRequestId: $prId, event: APPROVE}) { | |
pullRequestReview { | |
id | |
} | |
} | |
}' -f prId=$prId | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
shell: pwsh | |
- name: Merge pull request | |
run: | | |
$prId = gh pr list --head version-sync-branch --json id --jq '.[0].id' | |
gh pr merge $prId --squash --delete-branch --admin | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
shell: pwsh | |
######################## build/publish yak ########################## | |
build_yak: | |
runs-on: windows-latest | |
needs: sync_version | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Python setup | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.9.10' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install invoke | |
pip install pythonnet | |
# install dotnet for building the RhinoCs plugin | |
- name: Install .NET Framework 4.8 | |
uses: microsoft/[email protected] | |
- name: Run Invoke Yakerizer task | |
run: invoke yakerize | |
- name: Save artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: scriptsync_yak_package | |
path: yaker\build\*.yak | |
publish_yak: | |
needs: build_yak | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Download artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: scriptsync_yak_package | |
path: yaker\build | |
- name: Publish to Yak test server | |
run: | | |
$YAK_FILE=$(ls *.yak) | |
echo "Yak file: $YAK_FILE" | |
..\exec\Yak.exe push --source https://test.yak.rhino3d.com $YAK_FILE | |
working-directory: yaker\build | |
env: | |
YAK_TOKEN: ${{ secrets.YAK_IBOIS_TOKEN }} | |
continue-on-error: true | |
- name: Verify the Yak test package | |
run: | | |
..\exec\Yak.exe search --source https://test.yak.rhino3d.com --all --prerelease script-sync | |
working-directory: yaker\build | |
env: | |
YAK_TOKEN: ${{ secrets.YAK_IBOIS_TOKEN }} | |
- name: Publish to Yak server | |
run: | | |
$YAK_FILE=$(ls *.yak) | |
echo "Yak file: $YAK_FILE" | |
..\exec\Yak.exe push $YAK_FILE | |
working-directory: yaker\build | |
env: | |
YAK_TOKEN: ${{ secrets.YAK_IBOIS_TOKEN }} | |
# check the real release | |
- name: Verify the Yak test package | |
run: | | |
..\exec\Yak.exe search --all --prerelease script-sync | |
working-directory: yaker\build | |
env: | |
YAK_TOKEN: ${{ secrets.YAK_IBOIS_TOKEN }} | |
######################## build/publish vsix ######################### | |
build_vsix: | |
runs-on: windows-latest | |
needs: sync_version | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
- name: Python setup | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Install pip and invoke | |
run: | | |
python -m pip install --upgrade pip | |
pip install invoke | |
- name: Install vsce | |
run: npm install -g vsce | |
- name: Build VSIX package | |
run: | | |
cd VSCode/scriptsync | |
npm install | |
vsce package | |
- name: Save artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: script-sync-vsix | |
path: VSCode/scriptsync/*.vsix | |
publish_vsix: | |
needs: build_vsix | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v2 | |
- name: Python setup | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Install pip and invoke | |
run: | | |
python -m pip install --upgrade pip | |
pip install invoke | |
- name: Install VSCE | |
run: npm install -g vsce | |
- name: Install TypeScript | |
run: npm install -g typescript | |
- name: Install dependencies | |
run: | | |
npm install | |
npm install @types/vscode | |
npm install @types/mocha --save-dev | |
- name: Download artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: script-sync-vsix | |
path: VSCode\scriptsync | |
- name: Get the full path of the downloaded vsix artifact | |
id: get_vsix_path | |
run: | | |
echo "::set-output name=vsix_path::$(find VSCode/scriptsync -name '*.vsix')" | |
shell: bash | |
- name: Publish to VSCode Marketplace | |
run: | | |
vsce publish -p ${{ secrets.AZURE_OP_TOKEN }} --packagePath ${{ steps.get_vsix_path.outputs.vsix_path }} | |
working-directory: .\VSCode\scriptsync | |
- name: Verify the VSCode Marketplace package | |
run: | | |
vsce show ibois-epfl.script-sync | |
###################### release artifacts ######################## | |
release_artifacts: | |
needs: [build_yak, build_vsix] | |
runs-on: ubuntu-latest | |
if: github.event_name == 'release' | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Download Yak artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: scriptsync_yak_package | |
path: yaker/build | |
- name: Download VSIX artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: script-sync-vsix | |
path: VSCode/scriptsync | |
# # list what's in the directory VSCode\scriptsync | |
# - name: List VSIX artifact | |
# run: | | |
# ls -la VSCode/scriptsync | |
# shell: bash | |
# get the path of the name terminating with .vsix and set it to a variable | |
- name: Get VSIX artifact path and save it to an output | |
id: get_vsix_path | |
run: | | |
echo "::set-output name=vsix_path::$(find VSCode/scriptsync -name '*.vsix')" | |
shell: bash | |
- name: Get YAK artifact path | |
id: get_yak_path | |
run: | | |
echo "::set-output name=yak_path::$(find yaker/build -name '*.yak')" | |
shell: bash | |
- name: Print VSIX artifact path | |
run: | | |
echo ${{ steps.get_vsix_path.outputs.vsix_path }} | |
shell: bash | |
- name: Print YAK artifact path | |
run: | | |
echo ${{ steps.get_yak_path.outputs.yak_path }} | |
shell: bash | |
- name: Upload .vsix artifact | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ github.event.release.upload_url }} | |
asset_path: ${{ steps.get_vsix_path.outputs.vsix_path }} | |
asset_name: script-sync-vsix.vsix | |
asset_content_type: application/octet-stream | |
- name: Upload .yak artifact | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ github.event.release.upload_url }} | |
asset_path: ${{ steps.get_yak_path.outputs.yak_path }} | |
asset_name: script-sync.yak | |
asset_content_type: application/octet-stream |