Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/naming-convention": [
"warn",
{
"selector": "import",
"format": ["camelCase", "PascalCase"]
}
],
"@typescript-eslint/semi": "warn",
"curly": "warn",
"eqeqeq": "warn",
"no-throw-literal": "warn",
"semi": "off"
},
"ignorePatterns": ["out", "dist", "**/*.d.ts"]
}
96 changes: 96 additions & 0 deletions .github/workflows/build-extension.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Build and Publish Extension

on:
workflow_call:
inputs:
os_target:
description: "target architecture" # linux-x64, darwin-arm64
required: true
type: string
os_name:
description: "operating system" # ubuntu-latest, macos-latest
required: true
type: string
secrets:
VAULT_TOKEN:
required: true

jobs:
build_extension:
runs-on: [self-hosted, ubuntu-22-04, regular]

steps:
- name: Checkout this repository
uses: actions/checkout@v4

- name: Setup Node.js latest
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "npm"

- name: Download fastedge-cli Artifact
uses: actions/download-artifact@v4
with:
name: fastedge-cli-${{ inputs.os_name }}-artifact
path: fastedge-cli

- name: Install dependencies
run: |
npm ci

- name: Extract tag version
id: extract_version
run: |
TAG_VERSION=${GITHUB_REF#refs/tags/}
TAG_VERSION=${TAG_VERSION#v} # Remove the 'v' prefix
echo "TAG_VERSION=$TAG_VERSION" >> $GITHUB_ENV

- name: Update package.json version
run: |
jq --arg version "$TAG_VERSION" '.version = $version' package.json > package.tmp.json
mv package.tmp.json package.json

- name: Build JavaScript extension
run: |
npm run build

- name: List extension files
run: |
npx vsce ls

- name: Ensure extension is exectuable
run: |
chmod +x ./fastedge-cli/cli-${{ inputs.os_target }}

- name: Package extension
run: |
npx @vscode/vsce package --target ${{ inputs.os_target }}
FILENAME=$(ls *.vsix)
echo "VSIX_FILENAME=$FILENAME" >> $GITHUB_ENV

- name: Create SHA256 checksum
run: |
shasum -a 256 $VSIX_FILENAME > $VSIX_FILENAME.sha256
echo "ASSET=$VSIX_FILENAME" >> $GITHUB_ENV
echo "ASSET_SUM=$VSIX_FILENAME.sha256" >> $GITHUB_ENV

- name: Upload release archive
uses: softprops/action-gh-release@v2
with:
files: |
${{ env.ASSET }}
${{ env.ASSET_SUM }}

- name: Import Personal Access Token
uses: hashicorp/vault-action@v3
id: secrets
with:
url: https://puppet-vault.gc.onl
token: ${{ secrets.VAULT_TOKEN }}
secrets: |
secret/project_fastedge/vscode_marketplace publish_token | PUBLISH_TOKEN ;

- name: Publish extension to VS Marketplace
run: |
npx @vscode/vsce publish --target ${{ inputs.os_target }} --pat ${{ steps.secrets.outputs.PUBLISH_TOKEN }}
76 changes: 76 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Create a versioned release

on:
push:
tags:
- "v[0-9]+.*"

workflow_dispatch: # trigger manually
inputs:
cli_version:
description: "FastEdge cli version"
required: true
default: "latest"
tag_version:
description: "Release tag e.g. v1.0.1"
required: true
default: ""

jobs:
check_tags:
runs-on: [self-hosted, ubuntu-22-04, regular]
outputs:
has_release_tag: ${{ steps.determine-tag.outputs.has_tag }}

steps:
- name: Checkout this repository
uses: actions/checkout@v4

- name: Create release tag
id: determine-tag
run: |
if [ -n "${{ github.event.inputs.tag_version }}" ]; then
TAG_VERSION="${{ github.event.inputs.tag_version }}"
if [[ ! "$TAG_VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)?$ ]]; then
echo "Invalid tag format: $TAG_VERSION"
exit 1
fi
echo "Creating new release tag: $TAG_VERSION""
git tag -a $TAG_VERSION" -m "Release $TAG_VERSION""
git push origin $TAG_VERSION"
echo "has_tag=false" >> $GITHUB_OUTPUT
else
TAG_VERSION=${GITHUB_REF#refs/tags/}
if [[ ! "$TAG_VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)?$ ]]; then
echo "Invalid tag format: $TAG_VERSION"
exit 1
fi
echo "has_tag=true" >> $GITHUB_OUTPUT
fi

download_fastedge_cli:
uses: ./.github/workflows/download-cli.yml
needs: check_tags
if: ${{ needs.check_tags.outputs.has_release_tag == 'true' }}
with:
cli_version: ${{ inputs.cli_version }}

build_linux_extension:
uses: ./.github/workflows/build-extension.yml
needs: ["check_tags", "download_fastedge_cli"]
if: ${{ needs.check_tags.outputs.has_release_tag == 'true' }}
with:
os_target: linux-x64
os_name: ubuntu-latest
secrets:
VAULT_TOKEN: ${{ secrets.VAULT_TOKEN }}

build_darwin_extension:
uses: ./.github/workflows/build-extension.yml
needs: ["check_tags", "build_linux_extension"]
if: ${{ needs.check_tags.outputs.has_release_tag == 'true' }}
with:
os_target: darwin-arm64
os_name: macos-latest
secrets:
VAULT_TOKEN: ${{ secrets.VAULT_TOKEN }}
81 changes: 81 additions & 0 deletions .github/workflows/download-cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Get FastEdge-lib Assets

on:
workflow_call:
inputs:
cli_version:
description: "FastEdge cli version"
required: false
type: string
default: "latest"

jobs:
determine-cli-version:
runs-on: [self-hosted, ubuntu-22-04, regular]
outputs:
version: ${{ steps.determine-version.outputs.version }}
steps:
- name: Determine version
id: determine-version
run: |
if [ "${{ inputs.cli_version }}" == "latest" ] || [ -z "${{ inputs.cli_version }}" ]; then
echo "Fetching latest release version..."
LATEST_VERSION=$(curl -s https://api.github.com/repos/G-Core/FastEdge-lib/releases/latest | jq -r .tag_name)
echo "Latest version is $LATEST_VERSION"
echo "version=$LATEST_VERSION" >> $GITHUB_OUTPUT
else
echo "version=${{ inputs.cli_version }}" >> $GITHUB_OUTPUT
fi

download-and-verify:
runs-on: [self-hosted, ubuntu-22-04, regular]
needs: determine-cli-version
strategy:
matrix:
include:
- target: linux-x64
os: ubuntu-latest
file_suffix: x86_64-unknown-linux-gnu

- target: darwin-arm64
os: macos-latest
file_suffix: aarch64-apple-darwin

steps:
- name: Checkout this repository
uses: actions/checkout@v4

- name: Use version from determine-cli-version job
id: used-cli-version
run: |
echo "VERSION=${{ needs.determine-cli-version.outputs.version }}" >> $GITHUB_ENV

- name: Download FastEdge-lib assets
run: |
echo "Downloading version $VERSION for ${{ matrix.os }}"
curl -L -o cli-$VERSION-${{ matrix.file_suffix }}.tar.gz https://github.com/G-Core/FastEdge-lib/releases/download/$VERSION/cli-$VERSION-${{ matrix.file_suffix }}.tar.gz
curl -L -o cli-$VERSION-${{ matrix.file_suffix }}.tar.gz.sha256 https://github.com/G-Core/FastEdge-lib/releases/download/$VERSION/cli-$VERSION-${{ matrix.file_suffix }}.tar.gz.sha256

- name: Verify checksum
run: |
sha256sum -c cli-$VERSION-${{ matrix.file_suffix }}.tar.gz.sha256

- name: Extract fastedge-cli
run: |
tar -xzf cli-$VERSION-${{ matrix.file_suffix }}.tar.gz

- name: Rename and copy fastedge-cli
run: |
cp cli-$VERSION-${{ matrix.file_suffix }}/cli ./fastedge-cli/cli-${{ matrix.target }}

- name: Create a RELEASE.json file
run: |
echo "{\"fastedge_cli_version\": \"$VERSION\"}" > fastedge-cli/METADATA.json

- name: Upload fastedge-cli Artifact
uses: actions/upload-artifact@v4
with:
name: fastedge-cli-${{ matrix.os }}-artifact
retention-days: 1
path: |
fastedge-cli/
78 changes: 0 additions & 78 deletions .github/workflows/main.yml

This file was deleted.

22 changes: 18 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,26 @@
# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/
# Dependency directories
node_modules

# Go workspace file
go.work
# fastedge-cli - should be downloaded during build from https://github.com/G-Core/FastEdge-lib/releases
fastedge-cli/

# VSCode workspace
.vscode/

# VSIX package
fastedge-*.vsix

# Build files
build/
**/target/
dist/
exampleFolder/target/
runner
distr/
js-extension/

# Dev tools
.nx
Loading