From 2f40b20bdfe54d7e7486407c002f72f072b180be Mon Sep 17 00:00:00 2001 From: Muhammad Nawaz Date: Sun, 16 Jun 2024 14:25:26 +0500 Subject: [PATCH] Updated workflow to upload artifacts --- .github/workflows/create-release.yml | 79 ++++++++++++---------------- 1 file changed, 34 insertions(+), 45 deletions(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 29eb76f..d40ef38 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -1,64 +1,53 @@ -name: Create and Upload Release +name: Release on: push: tags: - - '*' + - 'v*.*.*' jobs: build: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v2 with: - submodules: true + submodules: true # Include submodules + fetch-depth: 0 - - name: Set up Git + - name: Create tar.gz archive run: | - git config --global user.name "GitHub Actions" - git config --global user.email "actions@github.com" + mkdir -p release + git archive --format=tar.gz --prefix=cpp-oasvalidator-${GITHUB_REF#refs/tags/}/ HEAD > release/cpp-oasvalidator-${GITHUB_REF#refs/tags/}.tar.gz + cd release + tar -xzf cpp-oasvalidator-${GITHUB_REF#refs/tags/}.tar.gz + git submodule foreach --recursive 'git archive --format=tar.gz --prefix=$path/ HEAD > ../$path.tar.gz' + for f in *.tar.gz; do tar -xzf "$f"; done + rm *.tar.gz + cd .. + tar -czf cpp-oasvalidator-${GITHUB_REF#refs/tags/}.tar.gz -C release . - - name: Create release archives + - name: Create zip archive run: | - TAG=${GITHUB_REF#refs/tags/} - # Create tar.gz archive - git archive --format=tar.gz --prefix=cpp-oasvalidator-${TAG}/ -o cpp-oasvalidator-${TAG}.tar.gz ${TAG} - # Create zip archive - git archive --format=zip --prefix=cpp-oasvalidator-${TAG}/ -o cpp-oasvalidator-${TAG}.zip ${TAG} - - # Include submodules - TEMP_DIR=$(mktemp -d) - git clone --recursive . $TEMP_DIR/cpp-oasvalidator-${TAG} - - # Add submodule content to tar.gz archive - tar -czf cpp-oasvalidator-${TAG}-with-submodules.tar.gz -C $TEMP_DIR cpp-oasvalidator-${TAG} - mv cpp-oasvalidator-${TAG}-with-submodules.tar.gz cpp-oasvalidator-${TAG}.tar.gz - - # Add submodule content to zip archive - (cd $TEMP_DIR && zip -r cpp-oasvalidator-${TAG}-with-submodules.zip cpp-oasvalidator-${TAG}) - mv $TEMP_DIR/cpp-oasvalidator-${TAG}-with-submodules.zip cpp-oasvalidator-${TAG}.zip - - # Clean up - rm -rf $TEMP_DIR + mkdir -p release + git archive --format=zip --prefix=cpp-oasvalidator-${GITHUB_REF#refs/tags/}/ HEAD > release/cpp-oasvalidator-${GITHUB_REF#refs/tags/}.zip + cd release + unzip cpp-oasvalidator-${GITHUB_REF#refs/tags/}.zip + git submodule foreach --recursive 'git archive --format=zip --prefix=$path/ HEAD > ../$path.zip' + for f in *.zip; do unzip "$f"; done + rm *.zip + cd .. + zip -r cpp-oasvalidator-${GITHUB_REF#refs/tags/}.zip release - - name: Upload tar.gz to release - uses: svenstaro/upload-release-action@v2 + - name: Upload Release Assets + uses: actions/upload-artifact@v2 with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: cpp-oasvalidator-${TAG}.tar.gz - asset_name: cpp-oasvalidator-${TAG}.tar.gz - tag: ${{ github.ref }} - overwrite: true - body: "Release ${TAG}" + name: release-asset-tar + path: cpp-oasvalidator-${GITHUB_REF#refs/tags/}.tar.gz - - name: Upload zip to release - uses: svenstaro/upload-release-action@v2 + - name: Upload Release Assets + uses: actions/upload-artifact@v2 with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: cpp-oasvalidator-${TAG}.zip - asset_name: cpp-oasvalidator-${TAG}.zip - tag: ${{ github.ref }} - overwrite: true - body: "Release ${TAG}" + name: release-asset-zip + path: cpp-oasvalidator-${GITHUB_REF#refs/tags/}.zip