From 55366a131e708b1785b9051055d669f22359afeb Mon Sep 17 00:00:00 2001 From: Kukks Date: Wed, 8 Nov 2023 10:53:45 +0100 Subject: [PATCH] auto build package with tag --- .../workflows/delete-old-workflow-runs.yml | 47 ------------ .github/workflows/publish-btcpay.yml | 54 +++++++++++++ .github/workflows/publish-nightly.yml | 75 ------------------- .github/workflows/publish-release.yml | 70 ----------------- build-btcpayplugin.sh | 16 ++++ .../Smartstore.BTCPayServer/module.json | 2 +- .../Smartstore.PackagerCLI.csproj | 3 + 7 files changed, 74 insertions(+), 193 deletions(-) delete mode 100644 .github/workflows/delete-old-workflow-runs.yml create mode 100644 .github/workflows/publish-btcpay.yml delete mode 100644 .github/workflows/publish-nightly.yml delete mode 100644 .github/workflows/publish-release.yml create mode 100644 build-btcpayplugin.sh diff --git a/.github/workflows/delete-old-workflow-runs.yml b/.github/workflows/delete-old-workflow-runs.yml deleted file mode 100644 index 0c4672d5c3..0000000000 --- a/.github/workflows/delete-old-workflow-runs.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Delete old workflow runs -on: - schedule: - # Run monthly, at 00:00 on the 1st day of month. - - cron: '0 0 1 * *' - workflow_dispatch: - inputs: - days: - description: 'Number of days.' - required: true - default: '30' - minimum_runs: - description: 'The minimum runs to keep for each workflow.' - required: true - default: '6' - delete_workflow_pattern: - description: 'The name or filename of the workflow. if not set then it will target all workflows.' - required: false - delete_workflow_by_state_pattern: - description: 'Remove workflow by state: active, deleted, disabled_fork, disabled_inactivity, disabled_manually' - required: true - default: "All" - type: choice - options: - - "All" - - active - - deleted - - disabled_inactivity - - disabled_manually - dry_run: - description: 'Only log actions, do not perform any delete operations.' - required: false - -jobs: - del_runs: - runs-on: ubuntu-latest - steps: - - name: Delete workflow runs - uses: Mattraks/delete-workflow-runs@v2 - with: - token: ${{ github.token }} - repository: ${{ github.repository }} - retain_days: ${{ github.event.inputs.days }} - keep_minimum_runs: ${{ github.event.inputs.minimum_runs }} - delete_workflow_pattern: ${{ github.event.inputs.delete_workflow_pattern }} - delete_workflow_by_state_pattern: ${{ github.event.inputs.delete_workflow_by_state_pattern }} - dry_run: ${{ github.event.inputs.dry_run }} diff --git a/.github/workflows/publish-btcpay.yml b/.github/workflows/publish-btcpay.yml new file mode 100644 index 0000000000..872e53719c --- /dev/null +++ b/.github/workflows/publish-btcpay.yml @@ -0,0 +1,54 @@ +name: Create Release + +on: + create: + tags: + - 'BTCPayServer/*' + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up .NET 7 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '7.x' # Use .NET 7 + + - name: Run build script and capture output + run: | + chmod +x ./build-btcpayplugin.sh + ASSET_PATH=$(./build-btcpayplugin.sh | tail -1) + echo "ASSET_PATH=$ASSET_PATH" >> $GITHUB_ENV + + - name: Verify tag matches asset file name + run: | + TAG_NAME=${GITHUB_REF#refs/tags/BTCPayServer/} + ASSET_BASE_NAME=$(basename $ASSET_PATH .zip) + if [[ "$ASSET_BASE_NAME" != *"$TAG_NAME" ]]; then + echo "Error: Tag name does not match asset file name." + exit 1 + fi + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + + - name: Upload Release Asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ${{ env.ASSET_PATH }} + asset_name: $(basename ${{ env.ASSET_PATH }}) + asset_content_type: application/zip diff --git a/.github/workflows/publish-nightly.yml b/.github/workflows/publish-nightly.yml deleted file mode 100644 index 3d2da6d2a1..0000000000 --- a/.github/workflows/publish-nightly.yml +++ /dev/null @@ -1,75 +0,0 @@ -name: Publish nightly dev Docker image - -on: - # Manual trigger - workflow_dispatch: - # At 06:00 AM, on Tuesday, Thursday, and Saturday - schedule: - - cron: "0 6 * * TUE,THU,SAT" - -env: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - DOTNET_CLI_TELEMETRY_OPTOUT: true - -jobs: - - publish-nightly: - name: Build, Test, Publish and Deploy nightly Docker image - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest] - permissions: - contents: read - packages: write - # This is used to complete the identity challenge - # with sigstore/fulcio when running outside of PRs. - id-token: write - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Setup .NET - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 7.0.x - include-prerelease: true - - - name: Build - run: dotnet build Smartstore.sln -c Release - - - name: Test - run: dotnet test Smartstore.sln -c Release --no-restore --no-build - - - name: Log in to the GitHub Container registry - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - #- name: Log in to Docker Hub - # uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 - # with: - # username: ${{ secrets.DOCKER_USERNAME }} - # password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Publish and Push for Linux - if: matrix.os == 'ubuntu-latest' - run: | - dotnet publish src/Smartstore.Web/Smartstore.Web.csproj -c Release -o ./.build/release --no-restore --no-build --no-self-contained - docker build --build-arg SOURCE=./.build/release -f NoBuild.Dockerfile -t ghcr.io/smartstore/smartstore-linux:nightly . - docker push ghcr.io/smartstore/smartstore-linux:nightly - #docker build --build-arg VERSION=nightly -f NoBuild.Dockerfile -t smartstore/smartstore-linux:nightly . - #docker push smartstore/smartstore-linux:nightly - - - name: Publish and Push for Windows - if: matrix.os == 'windows-latest' - run: | - dotnet publish src/Smartstore.Web/Smartstore.Web.csproj -c Release -o ./.build/release --no-restore --no-build --no-self-contained - docker build --build-arg SOURCE=./.build/release -f Nano.Dockerfile -t ghcr.io/smartstore/smartstore-windows:nightly . - docker push ghcr.io/smartstore/smartstore-windows:nightly - #docker build --build-arg VERSION=nightly -f NoBuild.Dockerfile -t smartstore/smartstore-windows:nightly . - #docker push smartstore/smartstore-windows:nightly diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml deleted file mode 100644 index 1299d6d6ca..0000000000 --- a/.github/workflows/publish-release.yml +++ /dev/null @@ -1,70 +0,0 @@ -name: Publish release Docker image - -on: - push: - branches: - - '5.0.5.x' # << Change this for new versions. - workflow_dispatch: - -env: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - DOTNET_CLI_TELEMETRY_OPTOUT: true - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - publish-release: - name: Build, Publish and Deploy stable release Docker image - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest] - permissions: - contents: read - packages: write - # This is used to complete the identity challenge - # with sigstore/fulcio when running outside of PRs. - id-token: write - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Format branch label - id: format-branch-label - run: bash .github/FormatBranchLabel.sh - - - name: Setup .NET - uses: actions/setup-dotnet@v3 - with: - dotnet-version: 7.0.x # << Change this to current .NET version. - include-prerelease: false - - - name: Build - run: dotnet build Smartstore.sln -c Release - - - name: Log in to the GitHub Container registry - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Publish and Push for Linux - if: matrix.os == 'ubuntu-latest' - run: | - dotnet publish src/Smartstore.Web/Smartstore.Web.csproj -c Release -o ./.build/release --no-restore --no-build --no-self-contained - docker build --build-arg SOURCE=./.build/release -f NoBuild.Dockerfile -t ghcr.io/smartstore/smartstore-linux:latest -t ghcr.io/smartstore/smartstore-linux:${{ steps.format-branch-label.outputs.branch-label }} . - docker push ghcr.io/smartstore/smartstore-linux:latest - docker push ghcr.io/smartstore/smartstore-linux:${{ steps.format-branch-label.outputs.branch-label }} - - - name: Publish and Push for Windows - if: matrix.os == 'windows-latest' - run: | - dotnet publish src/Smartstore.Web/Smartstore.Web.csproj -c Release -o ./.build/release --no-restore --no-build --no-self-contained - docker build --build-arg SOURCE=./.build/release -f Nano.Dockerfile -t ghcr.io/smartstore/smartstore-windows:latest -t ghcr.io/smartstore/smartstore-windows:${{ steps.format-branch-label.outputs.branch-label }} . - docker push ghcr.io/smartstore/smartstore-windows:latest - docker push ghcr.io/smartstore/smartstore-windows:${{ steps.format-branch-label.outputs.branch-label }} diff --git a/build-btcpayplugin.sh b/build-btcpayplugin.sh new file mode 100644 index 0000000000..0aed72b4ae --- /dev/null +++ b/build-btcpayplugin.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# Get the directory of the currently running script +StartPath=$(dirname "$0") + +# Print the StartPath +echo "$StartPath" + +# Build the project +dotnet build "$StartPath/src/Smartstore.Modules/Smartstore.BTCPayServer/Smartstore.BTCPayServer.csproj" -c Release + +# Print the path to the PackagerCLI project +echo "$StartPath/tools/Smartstore.PackagerCLI/Smartstore.PackagerCLI.csproj" + +# Run the PackagerCLI project +dotnet run --project "$StartPath/tools/Smartstore.PackagerCLI/Smartstore.PackagerCLI.csproj" "$StartPath/src/Smartstore.Web/Modules/Smartstore.BTCPayServer" "$StartPath/build/packages" diff --git a/src/Smartstore.Modules/Smartstore.BTCPayServer/module.json b/src/Smartstore.Modules/Smartstore.BTCPayServer/module.json index 6f97018042..e879f44c96 100644 --- a/src/Smartstore.Modules/Smartstore.BTCPayServer/module.json +++ b/src/Smartstore.Modules/Smartstore.BTCPayServer/module.json @@ -4,7 +4,7 @@ "SystemName": "Smartstore.BTCPayServer", "FriendlyName": "Bitcoin payments with BTCPay Server", "Description": "This plugin enables Bitcoin payments with your BTCPay Server instance", - "Version": "5.0.6.1", + "Version": "5.0.5", "MinAppVersion": "5.0.5", "Author": "Nisaba Solutions", "Order": 1, diff --git a/tools/Smartstore.PackagerCLI/Smartstore.PackagerCLI.csproj b/tools/Smartstore.PackagerCLI/Smartstore.PackagerCLI.csproj index fcbc97be43..685a4238b8 100644 --- a/tools/Smartstore.PackagerCLI/Smartstore.PackagerCLI.csproj +++ b/tools/Smartstore.PackagerCLI/Smartstore.PackagerCLI.csproj @@ -15,6 +15,9 @@ build-btcpayplugin.ps1 + + build-btcpayplugin.sh +