-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create GitHub action to keep ManagedBatchParser dependency up to date
- Loading branch information
1 parent
58ea619
commit aae9b7e
Showing
4 changed files
with
145 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
name: Update ManagedBatchParser | ||
|
||
on: | ||
schedule: | ||
- cron: "50 11 * * 0" # 11:50 am UTC, every Sunday | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
get_versions: | ||
name: Check current and latest ManagedBatchParser versions | ||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
current: ${{ steps.get_current.outputs.current }} | ||
latest: ${{ steps.output_jq.outputs.latest }} | ||
download_url: ${{ steps.output_jq.outputs.url }} | ||
|
||
steps: | ||
- id: create_dirs | ||
name: Create working directories | ||
run: | | ||
mkdir repo | ||
mkdir working | ||
- id: checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
path: repo | ||
|
||
- id: get_current | ||
name: Get currently-used version from version.txt | ||
working-directory: repo | ||
run: echo "current=$(cat src/DacpacTool/Microsoft.SqlTools.ManagedBatchParser/version.txt)" >> "$GITHUB_OUTPUT" | ||
|
||
# Get sqltoolsservice release metadata, | ||
# store in a file for later processing using JQ | ||
- id: curl_sqltoolsservice | ||
name: Get latest release metadata for sqltoolsservice | ||
working-directory: working | ||
run: curl https://api.github.com/repos/microsoft/sqltoolsservice/releases/latest | tee curl.txt | ||
|
||
- id: get_latest | ||
name: Get latest version number from release metadata | ||
uses: direct-actions/jq@v1 | ||
with: | ||
filter: '.tag_name' | ||
input-files: working/curl.txt | ||
raw-output: true | ||
|
||
- id: get_download_url | ||
name: Get download URL from release metadata | ||
uses: direct-actions/jq@v1 | ||
with: | ||
filter: '.assets[] | select(.content_type == "application/octet-stream") | select(.name | contains("ServiceLayer-linux-x64")) | .browser_download_url' | ||
input-files: working/curl.txt | ||
raw-output: true | ||
|
||
- id: output_jq | ||
name: Send parsed JSON data to output | ||
run: | | ||
echo "latest=${{ steps.get_latest.outputs.output }}" >> "$GITHUB_OUTPUT" | ||
echo "url=${{ steps.get_download_url.outputs.output }}" >> "$GITHUB_OUTPUT" | ||
compare_versions: | ||
name: Compare versions | ||
runs-on: ubuntu-latest | ||
needs: get_versions | ||
|
||
outputs: | ||
needs_update: ${{ steps.compare_versions.outputs.needs_update }} | ||
|
||
steps: | ||
# Set 'needs_update' based on whether versions match | ||
# (false if the versions match, true if they don't). | ||
# The create_pr job is conditional on this value | ||
- id: compare_versions | ||
name: Compare versions and determine if update is needed | ||
env: | ||
CURRENT: ${{needs.get_versions.outputs.current}} | ||
LATEST: ${{needs.get_versions.outputs.latest}} | ||
run: | | ||
needs_update=false | ||
[[ "$CURRENT" != "$LATEST" ]] && needs_update=true | ||
echo "needs_update=${needs_update}" >> "$GITHUB_OUTPUT" | ||
create_pr: | ||
name: Create pull request | ||
runs-on: ubuntu-latest | ||
needs: | ||
- get_versions | ||
- compare_versions | ||
if: ${{ needs.compare_versions.outputs.needs_update == 'true' }} | ||
|
||
steps: | ||
- id: create_dirs | ||
name: Create working directories | ||
run: | | ||
mkdir repo | ||
mkdir working | ||
- id: checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
path: repo | ||
|
||
- id: download | ||
name: Download release tarball | ||
working-directory: working | ||
env: | ||
DOWNLOAD_URL: ${{needs.get_versions.outputs.download_url}} | ||
run: wget --output-document release.tar.gz "$DOWNLOAD_URL" | ||
|
||
- id: set_latest | ||
env: | ||
LATEST: ${{needs.get_versions.outputs.latest}} | ||
working-directory: working | ||
run: | | ||
tar \ | ||
--extract \ | ||
--file=release.tar.gz \ | ||
--overwrite \ | ||
Microsoft.SqlTools.ManagedBatchParser.dll | ||
cp \ | ||
Microsoft.SqlTools.ManagedBatchParser.dll \ | ||
../repo/src/DacpacTool/Microsoft.SqlTools.ManagedBatchParser | ||
echo "$LATEST" > ../repo/src/DacpacTool/Microsoft.SqlTools.ManagedBatchParser/version.txt | ||
- id: create_pr | ||
name: Create pull request | ||
uses: peter-evans/create-pull-request@v7 | ||
with: | ||
path: repo | ||
title: Update ManagedBatchParser version to ${{needs.get_versions.outputs.latest}} | ||
commit-message: Update ManagedBatchParser version to ${{needs.get_versions.outputs.latest}} | ||
body: Automated changes by [Update ManagedBatchParser action](https://github.com/rr-wfm/MSBuild.Sdk.SqlProj/blob/master/.github/workflows/update-managed-batch-parser.yml) | ||
branch: actions/managed-batch-parser-${{needs.get_versions.outputs.latest}} | ||
delete-branch: true |
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
File renamed without changes.
1 change: 1 addition & 0 deletions
1
src/DacpacTool/Microsoft.SqlTools.ManagedBatchParser/version.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5.0.20241218.1 |