name: release-archive-artifact.yml

on:
  push:
    # tags:
    #   - "v*.*.*"

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Create Build Environment
        run: cmake -E make_directory ${{runner.workspace}}/archive

      - name: Create Build Environment
        run: cmake -E make_directory ${{runner.workspace}}/archive_unzipped

      - name: working dir
        run: |
          pwd
          echo ${{runner.workspace}}
          echo ""
          ls ${{runner.workspace}}/HiGHS

        # ls 
        # echo $GITHUB_WORKSPACE

      - name:  Generate archive artifact
        run: |
          pwd
          cd ${{runner.workspace}}
          pwd
          tar -czvf source-archive.tar.gz HiGHS
          
        # --exclude='./archive'

      - name: unzip archive
        run: |
          cd ${{runner.workspace}}
          tar -xvzf source-archive.tar.gz -C ${{runner.workspace}}/archive_unzipped

      - name: ls unziped archive
        run: |
          cd ${{runner.workspace}}/archive_unzipped
          pwd
          ls
          cd HiGHS
          ls

      - name: copy archive
        run: |
          cp ${{runner.workspace}}/source-archive.tar.gz .
          ls

      - name: Release
        uses: softprops/action-gh-release@v2

        if: startsWith(github.ref, 'refs/tags/')
        with:
          files: |
            source-archive.tar.gz