diff --git a/.github/workflows/tests.yml b/.github/workflows/cli.yml similarity index 66% rename from .github/workflows/tests.yml rename to .github/workflows/cli.yml index c58ab778..518f0acb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/cli.yml @@ -1,38 +1,40 @@ -name: tests +name: CLI on: push: branches: [main] + paths: + - 'cli/**' + - '.github/workflows/cli.yml' pull_request: - workflow_call: + paths: + - 'cli/**' + - '.github/workflows/cli.yml' + workflow_dispatch: jobs: - test-server: - runs-on: ubuntu-22.04 - + lint: + runs-on: ubuntu-latest defaults: run: - working-directory: ./server - + working-directory: ./cli steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: installing dependencies - uses: ./.github/actions/install + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - - - name: Run unit tests - run: go test ./... + node-version: 20 + cache: "npm" + cache-dependency-path: ./cli/package-lock.json + - name: Install dependencies + run: npm ci + - name: Run code formatting and linting + run: npm run fmt:check - test-cli: + test: runs-on: ubuntu-22.04 - defaults: run: working-directory: ./cli - steps: - name: Checkout repository uses: actions/checkout@v4 @@ -40,19 +42,17 @@ jobs: with: node-version: 20 cache: "npm" - cache-dependency-path: ./server/pages/package-lock.json + cache-dependency-path: ./cli/package-lock.json - name: Install dependencies run: npm ci - name: Run unit tests run: npm test - functional-test-cli: + functional-test: runs-on: ubuntu-22.04 - defaults: run: working-directory: ./cli - steps: - name: Checkout repository uses: actions/checkout@v4 @@ -60,7 +60,7 @@ jobs: with: node-version: 20 cache: "npm" - cache-dependency-path: ./server/pages/package-lock.json + cache-dependency-path: ./cli/package-lock.json - name: Install dependencies run: npm ci - name: Setup wallet @@ -76,4 +76,4 @@ jobs: npm run build npm run start -- upload -y --wallet ./wallet_fullpower.yaml --password $WALLET_TEST_PASSWORD ../smart-contract/src/e2e/test-project/dist env: - WALLET_TEST_PASSWORD: ${{ secrets.WALLET_TEST_PASSWORD }} + WALLET_TEST_PASSWORD: ${{ secrets.WALLET_TEST_PASSWORD }} \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 93d97129..00000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,76 +0,0 @@ -name: Lint - -on: - push: - branches: [main] - pull_request: - -jobs: - lint-server: - runs-on: ubuntu-latest - - defaults: - run: - working-directory: ./server - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: installing dependencies - uses: ./.github/actions/install - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - - - name: run golangci-lint - uses: golangci/golangci-lint-action@v6 - with: - version: v1.59 - args: --timeout=3m - working-directory: ./server - - - name: install gofumpt - run: go install mvdan.cc/gofumpt@latest - - - name: run gofumpt - run: | - ERRORS=$(gofumpt -l . | wc -l) - if [[ "$ERRORS" != "0" ]]; then - echo "following files are not gofumpted:" - gofumpt -l . - exit 1 - fi - - lint-cli: - runs-on: ubuntu-latest - defaults: - run: - working-directory: ./cli - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: "npm" - cache-dependency-path: ./cli/package-lock.json - - name: Install dependencies - run: npm ci - - name: Run code formating and linting - run: npm run fmt:check - - lint-frontend: - runs-on: ubuntu-latest - defaults: - run: - working-directory: ./server/pages - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: "npm" - cache-dependency-path: ./server/pages/package-lock.json - - name: Install dependencies - run: npm ci - - name: Run code formating and linting - run: npm run lint:check diff --git a/.github/workflows/plugin-release.yml b/.github/workflows/plugin-release.yml new file mode 100644 index 00000000..6414932c --- /dev/null +++ b/.github/workflows/plugin-release.yml @@ -0,0 +1,93 @@ +name: Plugin Release + +on: + workflow_dispatch: + inputs: + version: + description: 'Plugin version for this release (without v prefix)' + required: true + type: string + release-as-draft: + description: "Whether it's a draft or not" + required: true + type: boolean + default: true + release-as-prerelease: + description: "Whether it's a prerelease or not" + required: true + type: boolean + default: false + generate-release-notes: + description: "Generate release notes" + required: true + type: boolean + default: true + +jobs: + check-manifest: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Check the manifest version + working-directory: ./plugin + run: | + sudo apt-get install -y jq + version=$(jq -r '.version' manifest.json) + input_version=${{ inputs.version }} + if [[ "$version" != "$input_version" ]]; then + echo "ERROR: The manifest version ($version) does not match the input version ($input_version)" + exit 1 + fi + echo "Manifest version matches input version: $version" + + build-plugin: + uses: ./.github/workflows/plugin.yml + needs: check-manifest + with: + version: ${{ inputs.version }} + secrets: inherit + + create-release: + needs: [check-manifest, build-plugin] + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + pattern: 'deweb-plugin_*' + + - name: List artifacts + run: ls -R artifacts + + - name: Create zip packages for each platform + run: | + mkdir -p release_zips + + # Find all artifact folders + for platform_dir in artifacts/deweb-plugin_*; do + # Extract the platform name from the directory + platform_name=$(basename "$platform_dir") + + # Create a zip package for this platform + (cd "$platform_dir" && zip -r "../../release_zips/${platform_name}.zip" *) + + echo "Created zip package for $platform_name" + done + + ls -la release_zips/ + + - name: Create Release + uses: softprops/action-gh-release@v2 + with: + tag_name: plugin-v${{ inputs.version }} + name: plugin v${{ inputs.version }} + draft: ${{ inputs.release-as-draft }} + prerelease: ${{ inputs.release-as-prerelease }} + generate_release_notes: ${{ inputs.generate-release-notes }} + files: | + release_zips/*.zip diff --git a/.github/workflows/build.yml b/.github/workflows/plugin.yml similarity index 53% rename from .github/workflows/build.yml rename to .github/workflows/plugin.yml index 8bf3bb87..814e284d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/plugin.yml @@ -1,84 +1,67 @@ -name: build and upload artifacts +name: Plugin on: push: branches: [main] + paths: + - 'plugin/**' + - 'server/**' + - '.github/workflows/plugin.yml' pull_request: + paths: + - 'plugin/**' + - 'server/**' + - '.github/workflows/plugin.yml' workflow_dispatch: workflow_call: inputs: - tag_name: + version: type: string - description: "The tag name of the release without v prefix" + description: "Version for the build, without v prefix" + required: false env: - VERSION: ${{ inputs.tag_name }} + VERSION: ${{ inputs.version }} jobs: - build: - name: build and upload artifacts - strategy: - matrix: - include: - - os: windows-2022 - arch: amd64 - target: windows - ext: .exe - - os: ubuntu-22.04 - arch: amd64 - target: linux - - os: ubuntu-22.04 - arch: arm64 - target: linux - - os: macos-13 - arch: amd64 - target: darwin - - os: macos-14 - arch: arm64 - target: darwin - - runs-on: ${{ matrix.os }} - + lint: + runs-on: ubuntu-latest defaults: run: - working-directory: ./server - + working-directory: ./plugin steps: - name: Checkout repository uses: actions/checkout@v4 - - name: installing dependencies + - name: Installing dependencies uses: ./.github/actions/install with: - os: ${{ matrix.os }} repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Check if VERSION exists - shell: bash - id: check_version - run: | - if [ ! -z "${{ env.VERSION }}" ]; then - echo "PRODUCTION=true" >> $GITHUB_ENV - fi + - name: Task generate + run: task generate - - name: Build Server - shell: bash - run: task build - env: - OS: ${{ matrix.target }} - ARCH: ${{ matrix.arch }} + - name: Run golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: v1.59 + args: --timeout=3m + working-directory: ./plugin - - name: Rename Server artifact - run: mv build/deweb-server${{ matrix.ext }} build/deweb-server_${{ matrix.target }}_${{ matrix.arch }}${{ matrix.ext }} + - name: Install gofumpt + run: go install mvdan.cc/gofumpt@v0.7.0 - - name: Upload Server artifact - uses: actions/upload-artifact@v4 - with: - name: deweb-server_${{ matrix.target }}_${{ matrix.arch }} - path: server/build/deweb-server_${{ matrix.target }}_${{ matrix.arch }}${{ matrix.ext }} + - name: Run gofumpt + run: | + ERRORS=$(gofumpt -l . | wc -l) + if [[ "$ERRORS" != "0" ]]; then + echo "following files are not gofumpted:" + gofumpt -l . + exit 1 + fi - build-plugin: - name: build and upload plugin artifact + build: + name: Build plugin strategy: matrix: include: @@ -100,16 +83,14 @@ jobs: target: darwin runs-on: ${{ matrix.os }} - defaults: run: working-directory: ./plugin - steps: - name: Checkout repository uses: actions/checkout@v4 - - name: installing dependencies + - name: Installing dependencies uses: ./.github/actions/install with: os: ${{ matrix.os }} @@ -118,12 +99,10 @@ jobs: - name: Install Plugin Go Dependencies run: task install shell: bash - working-directory: ./plugin - name: Go Generate Plugin run: task generate shell: bash - working-directory: ./plugin - name: Check if VERSION exists shell: bash @@ -143,12 +122,16 @@ jobs: - name: Rename Plugin artifact run: mv build/deweb-plugin${{ matrix.ext }} deweb-plugin_${{ matrix.target }}_${{ matrix.arch }}${{ matrix.ext }} + - name: Copy shared files to platform directory + shell: bash + run: | + mkdir -p platform_${{ matrix.target }}_${{ matrix.arch }} + cp deweb-plugin_${{ matrix.target }}_${{ matrix.arch }}${{ matrix.ext }} platform_${{ matrix.target }}_${{ matrix.arch }}/ + cp favicon.png platform_${{ matrix.target }}_${{ matrix.arch }}/ + cp manifest.json platform_${{ matrix.target }}_${{ matrix.arch }}/ + - name: Upload Plugin artifact uses: actions/upload-artifact@v4 with: name: deweb-plugin_${{ matrix.target }}_${{ matrix.arch }} - path: | - plugin/deweb-plugin_${{ matrix.target }}_${{ matrix.arch }}${{ matrix.ext }} - plugin/favicon.png - plugin/manifest.json - + path: plugin/platform_${{ matrix.target }}_${{ matrix.arch }}/ \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/server-release.yml similarity index 53% rename from .github/workflows/release.yml rename to .github/workflows/server-release.yml index 8245b8c7..f96f7e7b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/server-release.yml @@ -1,10 +1,10 @@ -name: Release workflow +name: Server Release on: workflow_dispatch: inputs: - tag_name: - description: "Version to produce" + version: + description: 'Server version for this release (without v prefix)' required: true type: string release-as-draft: @@ -22,39 +22,36 @@ on: required: true type: boolean default: true - + jobs: - validate-input: - name: if tag_name is provided it must not start with "v" - runs-on: ubuntu-latest - steps: - - name: Check if tag_name starts with "v" - run: | - if [[ "${{ github.event.inputs.tag_name }}" == v* ]]; then - echo "tag_name starts with v" - exit 1 - fi - - build-release: - needs: validate-input - uses: ./.github/workflows/build.yml - secrets: inherit + build-server: + uses: ./.github/workflows/server.yml with: - tag_name: ${{ github.event.inputs.tag_name }} + version: ${{ inputs.version }} + secrets: inherit create-release: - name: Release - needs: build-release - + needs: build-server runs-on: ubuntu-latest + permissions: + contents: write steps: - - uses: actions/download-artifact@v4 - - name: Create release and upload binaries + - name: Download all server artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + pattern: 'deweb-server_*' + + - name: List artifacts + run: ls -R artifacts + + - name: Create Release uses: softprops/action-gh-release@v2 with: - tag_name: v${{ inputs.tag_name }} + tag_name: v${{ inputs.version }} + name: server v${{ inputs.version }} draft: ${{ inputs.release-as-draft }} prerelease: ${{ inputs.release-as-prerelease }} generate_release_notes: ${{ inputs.generate-release-notes }} files: | - ./deweb-*/deweb-* + artifacts/deweb-server_*/deweb-server_* diff --git a/.github/workflows/server.yml b/.github/workflows/server.yml new file mode 100644 index 00000000..dd9946f2 --- /dev/null +++ b/.github/workflows/server.yml @@ -0,0 +1,133 @@ +name: Server + +on: + push: + branches: [main] + paths: + - 'server/**' + - '.github/workflows/server.yml' + pull_request: + paths: + - 'server/**' + - '.github/workflows/server.yml' + workflow_dispatch: + workflow_call: + inputs: + version: + type: string + description: "Version for the build, without v prefix" + required: false + +env: + VERSION: ${{ inputs.version }} + +jobs: + lint: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./server + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Installing dependencies + uses: ./.github/actions/install + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Run golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: v1.59 + args: --timeout=3m + working-directory: ./server + + - name: Install gofumpt + run: go install mvdan.cc/gofumpt@v0.7.0 + + - name: Run gofumpt + run: | + ERRORS=$(gofumpt -l . | wc -l) + if [[ "$ERRORS" != "0" ]]; then + echo "following files are not gofumpted:" + gofumpt -l . + exit 1 + fi + + test: + runs-on: ubuntu-22.04 + defaults: + run: + working-directory: ./server + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Installing dependencies + uses: ./.github/actions/install + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Run unit tests + run: go test ./... + + build: + name: Build server + strategy: + matrix: + include: + - os: windows-2022 + arch: amd64 + target: windows + ext: .exe + - os: ubuntu-22.04 + arch: amd64 + target: linux + - os: ubuntu-22.04 + arch: arm64 + target: linux + - os: macos-13 + arch: amd64 + target: darwin + - os: macos-14 + arch: arm64 + target: darwin + + runs-on: ${{ matrix.os }} + defaults: + run: + working-directory: ./server + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Installing dependencies + uses: ./.github/actions/install + with: + os: ${{ matrix.os }} + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Check if VERSION exists + shell: bash + id: check_version + run: | + if [ ! -z "${{ env.VERSION }}" ]; then + echo "PRODUCTION=true" >> $GITHUB_ENV + fi + + - name: Build Server + shell: bash + run: task build + env: + OS: ${{ matrix.target }} + ARCH: ${{ matrix.arch }} + + - name: Rename Server artifact + run: mv build/deweb-server${{ matrix.ext }} build/deweb-server_${{ matrix.target }}_${{ matrix.arch }}${{ matrix.ext }} + + - name: Upload Server artifact + uses: actions/upload-artifact@v4 + with: + name: deweb-server_${{ matrix.target }}_${{ matrix.arch }} + path: server/build/deweb-server_${{ matrix.target }}_${{ matrix.arch }}${{ matrix.ext }} \ No newline at end of file