Skip to content

Commit

Permalink
chore: add details to VS Code Extension updates (#339)
Browse files Browse the repository at this point in the history
* chore: fix sorting order of vscode.extensions

* docs: update tool version issue text

* chore: remove cmake.options.statusBarVisibility

Let's leave this one up to the user

* chore: add more details to dependency updates

* chore: fix missing 'shell' property

* ci: fix unbound variable access

* chore: fix heredoc streaming

* chore: fix variable type mismatch

* chore: simplify output

* chore: remove invalid output

* chore: fix multi-line output

* chore: add GitHub release details

* chore: add GH_TOKEN for gh cli

* chore: fix comment layout

* chore: prepare formatting for json output

* chore: include releasenotes for all versions between latests and current

* chore: better layout

* chore: last formatting fix

* docs: small description change

* refactor: escape '`' in shell code

* chore: output list of updated dependencies

* chore: remove accidentally pushed submodule

* Update release-please-config.json

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* chore: make chore releasable and refactor PR naming

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
rjaegers and github-actions[bot] committed Mar 12, 2024
1 parent cb909f8 commit b24a2b5
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 42 deletions.
1 change: 0 additions & 1 deletion .devcontainer/devcontainer-metadata-vscode.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"--compile-commands-dir=${userHome}/.amp"
],
"cmake.copyCompileCommands": "${userHome}/.amp/compile_commands.json",
"cmake.options.statusBarVisibility": "compact",
"cortex-debug.gdbPath": "gdb-multiarch",
"cortex-debug.objdumpPath": "arm-none-eabi-objdump",
"sonarlint.pathToCompileCommands": "/root/.amp/compile_commands.json"
Expand Down
23 changes: 0 additions & 23 deletions .devcontainer/update-vscode-extensions.sh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: "Container Size Diff"
description: "Creates a Markdown summary of the size differences between two containers"
description: "Creates a Markdown summary of the size difference between two container versions"

inputs:
from-container:
Expand All @@ -18,7 +18,7 @@ outputs:
runs:
using: "composite"
steps:
- run: echo "$GITHUB_ACTION_PATH" >> $GITHUB_PATH
- run: echo "$GITHUB_ACTION_PATH" >> "$GITHUB_PATH"
shell: bash
env:
GITHUB_ACTION_PATH: ${{ github.action_path }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ get_sizes_from_manifest ${TO_CONTAINER} TO_CONTAINER_SIZES

echo "## Compressed layer size comparison"
echo
echo "Comparing ${FROM_CONTAINER} to ${TO_CONTAINER}"
echo "Comparing \`${FROM_CONTAINER}\` to \`${TO_CONTAINER}\`"
echo
echo "| OS/Platform | Previous Size | Current Size | Delta |"
echo "|-------------|---------------|--------------|-------|"
Expand Down
42 changes: 42 additions & 0 deletions .github/actions/update-vscode-extensions/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
name: "Update VS Code Extensions"
description: "Updates version-pinned VS Code Extensions in JSON files"

inputs:
input-file:
description: "Input file in JSON format containing a list of version pinned VS Code Extensions under `customizations.vscode.extensions`"
required: true

outputs:
updated-dependencies:
description: "JSON array with the names of the updated dependencies"
value: ${{ steps.update-extensions.outputs.updated-dependencies }}
markdown-summary:
description: "Markdown summary of update result"
value: ${{ steps.update-extensions.outputs.markdown-summary }}

runs:
using: "composite"
steps:
- run: echo "$GITHUB_ACTION_PATH" >> "$GITHUB_PATH"
shell: bash
env:
GITHUB_ACTION_PATH: ${{ github.action_path }}
- run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y jq
sudo npm install -g @vscode/vsce
shell: bash
- run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "markdown-summary<<${EOF}" >> "${GITHUB_OUTPUT}"
echo "$(update-vscode-extensions.sh ${INPUT_FILE})" >> "${GITHUB_OUTPUT}"
echo "${EOF}" >> "${GITHUB_OUTPUT}"
echo "updated-dependencies=$(cat updated-extensions.json)" >> "${GITHUB_OUTPUT}"
rm updated-extensions.json
id: update-extensions
shell: bash
env:
INPUT_FILE: ${{ inputs.input-file }}
GH_TOKEN: ${{ github.token }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash

set -Eeuo pipefail

FILE=${1:?}
JSON=$(cat $FILE)
EXTENSIONS=
UPDATE_DETAILS_MARKDOWN=
UPDATED_EXTENSIONS_JSON="[]"

get_github_releasenotes() {
local GITHUB_URL=${1:?}
local CURRENT_RELEASE=${2:?}

gh release list --exclude-drafts --exclude-pre-releases -R $GITHUB_URL --json name,tagName --jq '.[]' | while read -r RELEASE;
do
NAME=$(echo "$RELEASE" | jq -r '.name')
TAG=$(echo "$RELEASE" | jq -r '.tagName')

if [[ $NAME == *$CURRENT_RELEASE* || $TAG == v$CURRENT_RELEASE ]];
then
break;
fi

printf "%s\n\n" "$(gh release view --json body --jq '.body' -R $GITHUB_URL $TAG)"
done
}

for EXTENSION in $(echo $JSON | jq -r '.[].customizations.vscode.extensions | flatten[]'); do
NAME="${EXTENSION%%@*}"
CURRENT_VERSION="${EXTENSION#*@}"

LATEST_NON_PRERELEASE_VERSION_JSON=$(vsce show --json $NAME | jq '[ .versions[] | select(.properties) | select(any(.properties[].key; contains("Microsoft.VisualStudio.Code.PreRelease")) | not) ][0]')
LATEST_NON_PRERELEASE_VERSION=$(echo $LATEST_NON_PRERELEASE_VERSION_JSON | jq -r '.version')

if [[ $CURRENT_VERSION != $LATEST_NON_PRERELEASE_VERSION ]];
then
GITHUB_URL=$(echo $LATEST_NON_PRERELEASE_VERSION_JSON | jq -r '.properties | map(select(.key == "Microsoft.VisualStudio.Services.Links.GitHub"))[] | .value')

RELEASE_DETAILS=$(get_github_releasenotes $GITHUB_URL $CURRENT_VERSION)
UPDATE_DETAILS_MARKDOWN=$(printf "Updates \`%s\` from %s to %s\n<details>\n<summary>Release notes</summary>\n<blockquote>\n\n%s\n</blockquote>\n</details>\n\n%s" $NAME $CURRENT_VERSION $LATEST_NON_PRERELEASE_VERSION "$RELEASE_DETAILS" "$UPDATE_DETAILS_MARKDOWN")
UPDATED_EXTENSIONS_JSON=$(echo $UPDATED_EXTENSIONS_JSON | jq -c '. += ["'$NAME'"]')
fi

EXTENSIONS="\"$NAME@$LATEST_NON_PRERELEASE_VERSION\",$EXTENSIONS"
done

EXTENSIONS=$(echo "[${EXTENSIONS::-1}]" | jq 'sort_by(. | ascii_downcase)')
echo $JSON | jq '.[].customizations.vscode.extensions = $extensions' --argjson extensions "$EXTENSIONS" > $FILE

echo "$UPDATE_DETAILS_MARKDOWN"
echo "$UPDATED_EXTENSIONS_JSON" > updated-extensions.json
6 changes: 2 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ updates:
update-types:
- minor
- patch
commit-message:
prefix: "ci(deps)"
- package-ecosystem: docker
directory: .devcontainer
schedule:
interval: daily
commit-message:
prefix: "feat(deps)"
- package-ecosystem: pip
directory: .devcontainer
schedule:
interval: daily
commit-message:
prefix: "feat(deps)"
2 changes: 1 addition & 1 deletion .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ jobs:
sbom: true
provenance: true
cache-from: type=gha
- uses: ./.github/container-size-diff
- uses: ./.github/actions/container-size-diff
id: container-size-diff
with:
from-container: ${{ env.REGISTRY }}/${{ github.repository }}:latest
Expand Down
19 changes: 13 additions & 6 deletions .github/workflows/update-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ jobs:
working-directory: .devcontainer
- uses: peter-evans/create-pull-request@a4f52f8033a6168103c2538976c07b467e8163bc # v6.0.1
with:
commit-message: "feat(deps): update apt dependencies"
commit-message: "chore(deps): update dependencies"
branch: feature/update-apt-dependencies
title: "feat(deps): update group apt dependencies"
title: "chore(deps): update dependencies"
labels: dependencies,apt
token: ${{ secrets.AMP_RELEASER_TOKEN }}
update-vscode-extensions:
Expand All @@ -36,12 +36,19 @@ jobs:
pull-requests: write
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- run: ./update-vscode-extensions.sh devcontainer-metadata-vscode.json
working-directory: .devcontainer
- uses: ./.github/actions/update-vscode-extensions
id: update-extensions
with:
input-file: .devcontainer/devcontainer-metadata-vscode.json
- uses: peter-evans/create-pull-request@a4f52f8033a6168103c2538976c07b467e8163bc # v6.0.1
with:
commit-message: "feat(deps): update vscode extensions"
commit-message: "chore(deps): update ${{ join(fromJson(steps.update-extensions.outputs.updated-dependencies), ', ') }}"
branch: feature/update-vscode-extensions
title: "feat(deps): update group vscode extensions"
body: |
${{ steps.update-extensions.outputs.markdown-summary }}
> [!NOTE]
> Before merging this PR, please conduct a manual test checking basic functionality of the updated plug-ins. There are no automated tests for the VS Code Extension updates.
title: "chore(deps): update ${{ join(fromJson(steps.update-extensions.outputs.updated-dependencies), ', ') }}"
labels: dependencies,vscode-extensions
token: ${{ secrets.AMP_RELEASER_TOKEN }}
25 changes: 21 additions & 4 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
{
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
"changelog-sections": [
{
"type": "feat",
"section": "Features",
"hidden": false
},
{
"type": "fix",
"section": "Bug Fixes",
"hidden": false
},
{
"type": "chore",
"section": "Chores",
"hidden": false
}
],
"include-component-in-tag": false,
"plugins": ["sentence-case"],
"packages": {
".": {
"release-type": "simple",
"package-name": "amp-devcontainer"
"package-name": "amp-devcontainer",
"release-type": "simple"
}
},
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
"plugins": ["sentence-case"]
}

0 comments on commit b24a2b5

Please sign in to comment.