summary refs log tree commit diff
path: root/.github/workflows/main.yml
blob: c7991e7a79269b642952f71af272f5950d7d3cea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Build and Release

on:
  push:
    tags:
      - 'v*'  # Trigger the workflow when a tag starting with 'v' is pushed (e.g., v1.0.0)

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v3

    - name: Set up Deno
      uses: denoland/setup-deno@61fe2df320078202e33d7d5ad347e7dcfa0e8f31
      with:
        deno-version: 'v2.0.6'
    
    - name: Install modulesdsafdasf
      run: deno install

    - name: Make shell script executable
      run: chmod +x ./buildall.sh

    - name: Run buildall.sh
      run: ./buildall.sh

    - name: List contents of build/compressed (debugging step)
      run: ls -R build/compressed

    - name: Upload build artifacts
      uses: actions/upload-artifact@v3
      with:
        name: compressed-files
        path: build/compressed/*

  release:
    needs: build
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v3

    - name: List contents of build/compressed (debugging step)
      run: ls -R build/compressed  # Double-check the files before uploading

    # Step to check if the release already exists
    - name: Check if release exists
      id: check_release
      run: |
        TAG="${GITHUB_REF##*/}"
        RELEASE=$(curl -s --header "Authorization: token ${{ secrets.GH_TOKEN }}" \
          "https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG")
        echo "Release: $RELEASE"
        if [[ "$RELEASE" != "{}" ]]; then
          echo "Release already exists for tag $TAG"
          echo "exists=true" >> $GITHUB_ENV
        else
          echo "Release does not exist for tag $TAG"
          echo "exists=false" >> $GITHUB_ENV

    # Conditional step to create release only if it doesn't exist
    - name: Create GitHub Release
      if: env.exists == 'false'
      uses: softprops/action-gh-release@v1
      with:
        files: build/compressed/*
        tag_name: ${{ github.ref }}
        name: Release ${{ github.ref }}  # Use name instead of release_name
        body: "Automated release for version ${{ github.ref }}"
      env:
        GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}