Skip to content

Commit ea8c2d2

Browse files
Refacto workflows (#261)
* Disable old workflows * Divide build and release workflow into a server and a plugin workflow * Add missing task generate * Add CLI workflow * Update plugin release workflow to use new artifact path for zip files * Add job needs in plugin release workflows * Remove obsolete GitHub workflows for build, linting, and testing * Apply CR comments
1 parent 07e5d4e commit ea8c2d2

File tree

6 files changed

+322
-192
lines changed

6 files changed

+322
-192
lines changed
Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,66 @@
1-
name: tests
1+
name: CLI
22

33
on:
44
push:
55
branches: [main]
6+
paths:
7+
- 'cli/**'
8+
- '.github/workflows/cli.yml'
69
pull_request:
7-
workflow_call:
10+
paths:
11+
- 'cli/**'
12+
- '.github/workflows/cli.yml'
13+
workflow_dispatch:
814

915
jobs:
10-
test-server:
11-
runs-on: ubuntu-22.04
12-
16+
lint:
17+
runs-on: ubuntu-latest
1318
defaults:
1419
run:
15-
working-directory: ./server
16-
20+
working-directory: ./cli
1721
steps:
18-
- name: Checkout repository
19-
uses: actions/checkout@v4
20-
21-
- name: installing dependencies
22-
uses: ./.github/actions/install
22+
- uses: actions/checkout@v4
23+
- uses: actions/setup-node@v4
2324
with:
24-
repo-token: ${{ secrets.GITHUB_TOKEN }}
25-
26-
- name: Run unit tests
27-
run: go test ./...
25+
node-version: 20
26+
cache: "npm"
27+
cache-dependency-path: ./cli/package-lock.json
28+
- name: Install dependencies
29+
run: npm ci
30+
- name: Run code formatting and linting
31+
run: npm run fmt:check
2832

29-
test-cli:
33+
test:
3034
runs-on: ubuntu-22.04
31-
3235
defaults:
3336
run:
3437
working-directory: ./cli
35-
3638
steps:
3739
- name: Checkout repository
3840
uses: actions/checkout@v4
3941
- uses: actions/setup-node@v4
4042
with:
4143
node-version: 20
4244
cache: "npm"
43-
cache-dependency-path: ./server/pages/package-lock.json
45+
cache-dependency-path: ./cli/package-lock.json
4446
- name: Install dependencies
4547
run: npm ci
4648
- name: Run unit tests
4749
run: npm test
4850

49-
functional-test-cli:
51+
functional-test:
5052
runs-on: ubuntu-22.04
51-
5253
defaults:
5354
run:
5455
working-directory: ./cli
55-
5656
steps:
5757
- name: Checkout repository
5858
uses: actions/checkout@v4
5959
- uses: actions/setup-node@v4
6060
with:
6161
node-version: 20
6262
cache: "npm"
63-
cache-dependency-path: ./server/pages/package-lock.json
63+
cache-dependency-path: ./cli/package-lock.json
6464
- name: Install dependencies
6565
run: npm ci
6666
- name: Setup wallet
@@ -76,4 +76,4 @@ jobs:
7676
npm run build
7777
npm run start -- upload -y --wallet ./wallet_fullpower.yaml --password $WALLET_TEST_PASSWORD ../smart-contract/src/e2e/test-project/dist
7878
env:
79-
WALLET_TEST_PASSWORD: ${{ secrets.WALLET_TEST_PASSWORD }}
79+
WALLET_TEST_PASSWORD: ${{ secrets.WALLET_TEST_PASSWORD }}

.github/workflows/lint.yml

Lines changed: 0 additions & 76 deletions
This file was deleted.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Plugin Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Plugin version for this release (without v prefix)'
8+
required: true
9+
type: string
10+
release-as-draft:
11+
description: "Whether it's a draft or not"
12+
required: true
13+
type: boolean
14+
default: true
15+
release-as-prerelease:
16+
description: "Whether it's a prerelease or not"
17+
required: true
18+
type: boolean
19+
default: false
20+
generate-release-notes:
21+
description: "Generate release notes"
22+
required: true
23+
type: boolean
24+
default: true
25+
26+
jobs:
27+
check-manifest:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
32+
33+
- name: Check the manifest version
34+
working-directory: ./plugin
35+
run: |
36+
sudo apt-get install -y jq
37+
version=$(jq -r '.version' manifest.json)
38+
input_version=${{ inputs.version }}
39+
if [[ "$version" != "$input_version" ]]; then
40+
echo "ERROR: The manifest version ($version) does not match the input version ($input_version)"
41+
exit 1
42+
fi
43+
echo "Manifest version matches input version: $version"
44+
45+
build-plugin:
46+
uses: ./.github/workflows/plugin.yml
47+
needs: check-manifest
48+
with:
49+
version: ${{ inputs.version }}
50+
secrets: inherit
51+
52+
create-release:
53+
needs: [check-manifest, build-plugin]
54+
runs-on: ubuntu-latest
55+
permissions:
56+
contents: write
57+
steps:
58+
- name: Download all artifacts
59+
uses: actions/download-artifact@v4
60+
with:
61+
path: artifacts
62+
pattern: 'deweb-plugin_*'
63+
64+
- name: List artifacts
65+
run: ls -R artifacts
66+
67+
- name: Create zip packages for each platform
68+
run: |
69+
mkdir -p release_zips
70+
71+
# Find all artifact folders
72+
for platform_dir in artifacts/deweb-plugin_*; do
73+
# Extract the platform name from the directory
74+
platform_name=$(basename "$platform_dir")
75+
76+
# Create a zip package for this platform
77+
(cd "$platform_dir" && zip -r "../../release_zips/${platform_name}.zip" *)
78+
79+
echo "Created zip package for $platform_name"
80+
done
81+
82+
ls -la release_zips/
83+
84+
- name: Create Release
85+
uses: softprops/action-gh-release@v2
86+
with:
87+
tag_name: plugin-v${{ inputs.version }}
88+
name: plugin v${{ inputs.version }}
89+
draft: ${{ inputs.release-as-draft }}
90+
prerelease: ${{ inputs.release-as-prerelease }}
91+
generate_release_notes: ${{ inputs.generate-release-notes }}
92+
files: |
93+
release_zips/*.zip

0 commit comments

Comments
 (0)