name: Release Workflow

on:
  workflow_dispatch:  
  
#on: # The workflow only runs with push a Git tag
#  push: 
#    tags:
#      - "v*.*.*" # v1.0.0, v2.5.3, v10.23.7

jobs:
  # Defines a job named release
  release:
    # According to the Gitea documentation, the ubuntu-latest label is mapped 
    # internally to Ubuntu 22.04 environments  
    runs-on: ubuntu-22.04
    steps:
      - name: Checkout code
        # Pulls your repo into the runner so it has access to the source code
        uses: actions/checkout@v4

      - name: Build artifact
        # Makes a directory dist/
        # Creates a file README.txt inside dist/
        # $GITHUB_REF_NAME is an environment variable set by Actions - 
        # it will be the name of the Git tag that triggered this workflow
        # If you pushed v1.2.3, the file will contain "Release version v1.2.3"
        # run, execute these shell commands
        # |, treat everything indented below this as a multi-line string, 
        # and keep line breaks as they are.
        # /workspace/<owner>/<repo>/dist/
        run: |
          mkdir dist
          echo "Release version $GITHUB_REF_NAME" > dist/README.txt
          echo "Ref $GITHUB_REF" >> dist/README.txt

      - name: Upload artifact
        # Packages whatever is inside dist/ (in this case, just the README.txt)
        # Uploads it to Gitea Actions as a downloadable artifact
        # In the Actions UI, after the run finishes, a link to download release-files.zip
        uses: actions/upload-artifact@v3
        with:
          name: release-files
          path: dist/
