Skip to content

Commit 3b0b840

Browse files
authored
Add workflows to release, version, and list Connect extensions (#35)
* Add extension section to extension manifests * Add empty start to extension list * Add extension GitHub actions * Add extension list script * Replace extension workflows with a single workflow
1 parent 50668cf commit 3b0b840

File tree

27 files changed

+739
-200
lines changed

27 files changed

+739
-200
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Lint Extension
2+
description: Lint an extension for release
3+
4+
inputs:
5+
extension-name:
6+
description: The name of the extension
7+
required: true
8+
type: string
9+
10+
runs:
11+
using: "composite"
12+
13+
steps:
14+
# Ensures that the manifest.json for the given extension name
15+
# contains all the required fields for the rest of the release workflow
16+
- run: |
17+
jq '
18+
if (.extension | type) != "object" then error("Missing extension object")
19+
elif (.extension.name | type) != "string" then error("Missing extension.name")
20+
elif (.extension.title | type) != "string" then error("Missing extension.title")
21+
elif (.extension.description | type) != "string" then error("Missing extension.description")
22+
elif (.extension.homepage | type) != "string" then error("Missing extension.homepage")
23+
elif (.extension.version | type) != "string" then error("Missing extension.version")
24+
else . end
25+
' ./extensions/${{ inputs.extension-name }}/manifest.json
26+
shell: bash
27+
28+
- uses: actions/setup-node@v4
29+
30+
- run: npm install -g semver
31+
shell: bash
32+
33+
# The semver must be valid for the sorting, comparisons, and release
34+
# process to work
35+
- name: Check for valid semver
36+
run: |
37+
semver -c $(jq -c -r '.extension.version' < ./extensions/${{ inputs.extension-name }}/manifest.json)
38+
shell: bash
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Package Extension
2+
description: Package an extension into a tarball for release
3+
4+
inputs:
5+
extension-name:
6+
description: The name of the extension
7+
required: true
8+
type: string
9+
artifact-name:
10+
description: The name of the artifact
11+
required: false
12+
type: string
13+
14+
runs:
15+
using: "composite"
16+
17+
steps:
18+
# If we are not passed an artifact to use as the source for the tarball
19+
# we will create a tarball from the extension's directory
20+
- name: Create tar
21+
if: ${{ inputs.artifact-name == '' }}
22+
run: tar -czf ${{ inputs.extension-name}}.tar.gz ./extensions/${{ inputs.extension-name}}
23+
shell: bash
24+
25+
# If we are passed an artifact to use as the source for the tarball
26+
# we will download the artifact and create a tarball from it
27+
# this avoids including extra files in the extension
28+
- name: Download optional artifact
29+
if: ${{ inputs.artifact-name != '' }}
30+
uses: actions/download-artifact@v4
31+
with:
32+
name: ${{ inputs.artifact-name }}
33+
path: ${{ inputs.extension-name }}
34+
35+
- name: Create tar from artifact
36+
if: ${{ inputs.artifact-name != '' }}
37+
run: tar -czf ${{ inputs.extension-name }}.tar.gz ${{ inputs.extension-name }}
38+
shell: bash
39+
40+
# Upload the extension's tarball for use in other actions in the workflow
41+
- name: Upload extension tar
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: ${{ inputs.extension-name }}.tar.gz
45+
path: ${{ inputs.extension-name }}.tar.gz
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Release Extension
2+
description: Release an extension as a GitHub Release
3+
4+
inputs:
5+
extension-name:
6+
description: The name of the extension
7+
required: true
8+
type: string
9+
10+
runs:
11+
using: "composite"
12+
13+
steps:
14+
- uses: actions/setup-node@v4
15+
16+
- run: npm install -g semver
17+
shell: bash
18+
19+
- name: Get manifest extension version
20+
run: |
21+
MANIFEST_VERSION=$(semver -c $(jq -c -r '.extension.version' < ./extensions/${{ inputs.extension-name }}/manifest.json))
22+
echo "MANIFEST_VERSION=$MANIFEST_VERSION" >> "$GITHUB_ENV"
23+
shell: bash
24+
25+
# Grabs the latest version from the extensions.json file
26+
# If an extension hasn't been released yet we default to `0.0.0` so any
27+
# version in the manifest will be higher
28+
- name: Get lastest version from extension list
29+
continue-on-error: true
30+
run: |
31+
LATEST_VERSION=$(jq -c '.extensions[] | select(.name=="${{ inputs.extension-name }}").latestVersion.version' < extensions.json)
32+
LATEST_VERSION=$(semver -c "${LATEST_VERSION:-0.0.0}")
33+
echo "LATEST_VERSION=$LATEST_VERSION" >> "$GITHUB_ENV"
34+
shell: bash
35+
36+
# We only want to release if the manifest.json contains a newer semver
37+
# version than the latest version in the extensions.json
38+
# We compare that here, and echo if a release will occur
39+
# This can be helpful when looking at Pull Request action outputs
40+
# so it is clear what will happen on a merge to `main`
41+
- name: Check if manifest has newer version
42+
id: should_release
43+
run: |
44+
echo "The manifest version is '$MANIFEST_VERSION' and the released version is '$LATEST_VERSION'"
45+
HIGHER_VERSION=$(semver "$MANIFEST_VERSION" "$LATEST_VERSION" | tail -n 1)
46+
if [ "$MANIFEST_VERSION" = "$HIGHER_VERSION" ] && [ "$MANIFEST_VERSION" != "$LATEST_VERSION" ]; then
47+
echo "🚀 Will release! The manifest version is greater than the released version."
48+
echo "should_release=true" >> "$GITHUB_OUTPUT"
49+
else
50+
echo "😴 Holding back from release: The manifest version is not greater than the released version."
51+
echo "should_release=false" >> "$GITHUB_OUTPUT"
52+
fi
53+
shell: bash
54+
55+
# Here we download the packaged extension artifact to release
56+
- uses: actions/download-artifact@v4
57+
if: github.ref_name == 'main' && steps.should_release.outputs.should_release == 'true'
58+
with:
59+
name: ${{ inputs.extension-name }}.tar.gz
60+
61+
# The release tag utilizes both the extension name and semver version
62+
# to create a unique tag for the repository
63+
- name: Release tag
64+
if: github.ref_name == 'main' && steps.should_release.outputs.should_release == 'true'
65+
id: release_tag
66+
run: |
67+
RELEASE_TAG="${{ inputs.extension-name }}@v$MANIFEST_VERSION"
68+
echo "RELEASE_TAG=$RELEASE_TAG" >> "$GITHUB_ENV"
69+
shell: bash
70+
71+
- name: Release
72+
if: github.ref_name == 'main' && steps.should_release.outputs.should_release == 'true'
73+
run: |
74+
gh release create $RELEASE_TAG \
75+
--title "${{ inputs.extension-name }} v$MANIFEST_VERSION" \
76+
${{ inputs.extension-name }}.tar.gz
77+
shell: bash
78+
79+
# We fetch the GitHub release using the GitHub API, storing the data
80+
# for use in the extension list update.
81+
- name: Get release data
82+
if: github.ref_name == 'main' && steps.should_release.outputs.should_release == 'true'
83+
run: gh api /repos/${{ github.repository }}/releases/tags/$RELEASE_TAG > release-${{ inputs.extension-name }}.json
84+
shell: bash
85+
86+
# Each release data file is uploaded as an artifact for the extension list update
87+
# The naming convention is `release-<extension-name>.json` to easily
88+
# download each artifact matching the pattern
89+
- name: Upload release data
90+
if: github.ref_name == 'main' && steps.should_release.outputs.should_release == 'true'
91+
uses: actions/upload-artifact@v4
92+
with:
93+
name: release-${{ inputs.extension-name }}.json
94+
path: release-${{ inputs.extension-name }}.json

.github/workflows/audit-api.yaml

Lines changed: 0 additions & 26 deletions
This file was deleted.

.github/workflows/audit-reports.yaml

Lines changed: 0 additions & 26 deletions
This file was deleted.

.github/workflows/datadog-prometheus-metrics.yaml

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)