Commit 0e51bc014d
Unregistered key
Layout: unified · split
.github/workflows/ci-cd.yml added +109
| @@ -0,0 +1,109 @@ | ||
| 1 | name: CI/CD Pipeline | |
| 2 | ||
| 3 | on: | |
| 4 | push: | |
| 5 | branches: | |
| 6 | - main # Trigger on pushes to the main branch | |
| 7 | pull_request: | |
| 8 | branches: | |
| 9 | - main # Trigger on pull requests targeting the main branch | |
| 10 | ||
| 11 | jobs: | |
| 12 | build: | |
| 13 | runs-on: ubuntu-latest | |
| 14 | ||
| 15 | steps: | |
| 16 | - name: Checkout code | |
| 17 | uses: actions/checkout@v2 | |
| 18 | ||
| 19 | - name: Set up Go | |
| 20 | uses: actions/setup-go@v2 | |
| 21 | with: | |
| 22 | go-version: '1.20' # Specify the Go version | |
| 23 | ||
| 24 | - name: Install Dependencies | |
| 25 | run: go mod tidy # Install Go dependencies | |
| 26 | ||
| 27 | - name: Comment go-winio for Linux Build | |
| 28 | run: | | |
| 29 | echo 'function toggle_winio_import() { | |
| 30 | local action="$1" | |
| 31 | local file="internal/player.go" | |
| 32 | ||
| 33 | if [ "$action" == "comment" ]; then | |
| 34 | sed -i "s|^\\(\\s*\\\"github.com/Microsoft/go-winio\\\"\\)|// \\1|" "$file" | |
| 35 | sed -i "s|^\\(.*conn, err = winio.DialPipe.*\\)|// \\1|" "$file" | |
| 36 | elif [ "$action" == "uncomment" ]; then | |
| 37 | sed -i "s|// \\(\\s*\\\"github.com/Microsoft/go-winio\\\"\\)|\\1|" "$file" | |
| 38 | sed -i "s|^// \\(.*conn, err = winio.DialPipe.*\\)|\\1|" "$file" | |
| 39 | fi | |
| 40 | } | |
| 41 | toggle_winio_import comment' > toggle_winio_import.sh | |
| 42 | ||
| 43 | - name: Execute Commenting Function for Linux Build # Comment out lines before Linux build | |
| 44 | run: | | |
| 45 | bash toggle_winio_import.sh | |
| 46 | ||
| 47 | - name: Build Linux binary | |
| 48 | run: | | |
| 49 | chmod +x Build/buildlinux | |
| 50 | ./Build/buildlinux | |
| 51 | ||
| 52 | - name: Revert Changes in player.go | |
| 53 | run: | | |
| 54 | git checkout -- internal/player.go | |
| 55 | ||
| 56 | - name: Build Windows binary | |
| 57 | run: | | |
| 58 | chmod +x Build/buildwindows | |
| 59 | ./Build/buildwindows | |
| 60 | ||
| 61 | # - name: Run Tests | |
| 62 | # run: go test ./... # Run tests for your Go code | |
| 63 | ||
| 64 | release: | |
| 65 | runs-on: windows-latest # Use Windows runner for creating the installer | |
| 66 | needs: build | |
| 67 | if: github.ref == 'refs/heads/main' && github.event_name == 'push' # Only run on pushes to main | |
| 68 | ||
| 69 | steps: | |
| 70 | - name: Checkout code | |
| 71 | uses: actions/checkout@v2 | |
| 72 | ||
| 73 | - name: Download Inno Setup # Clean up | |
| 74 | run: | | |
| 75 | Invoke-WebRequest -Uri "https://files.jrsoftware.org/download.php/is.exe" -OutFile "is.exe" # Download Inno Setup installer | |
| 76 | Start-Process -FilePath "is.exe" -ArgumentList "/SILENT" -Wait # Run installer silently | |
| 77 | Remove-Item "is.exe" | |
| 78 | ||
| 79 | - name: Create Windows Installer | |
| 80 | run: | | |
| 81 | & "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" Build/curd-windows-build.iss # Adjust the path to your Inno Setup script | |
| 82 | shell: pwsh # Use PowerShell shell | |
| 83 | ||
| 84 | - name: Bump Version | |
| 85 | id: bump_version | |
| 86 | run: | | |
| 87 | current_version=$(cat VERSION.txt) | |
| 88 | # Increment the patch version | |
| 89 | IFS='.' read -r major minor patch <<< "$current_version" | |
| 90 | new_patch=$((patch + 1)) | |
| 91 | new_version="$major.$minor.$new_patch" | |
| 92 | echo "$new_version" > VERSION.txt | |
| 93 | echo "New version: $new_version" | |
| 94 | git config user.name "GitHub Actions" | |
| 95 | git config user.email "actions@github.com" | |
| 96 | git add VERSION.txt | |
| 97 | git commit -m "Bump version to $new_version" | |
| 98 | git tag "v$new_version" | |
| 99 | ||
| 100 | - name: Create Release | |
| 101 | id: create_release | |
| 102 | uses: softprops/action-gh-release@v1 | |
| 103 | with: | |
| 104 | tag_name: ${{ steps.bump_version.outputs.new_version }} # Use the bumped version as tag | |
| 105 | release_name: "Curd v${{ steps.bump_version.outputs.new_version }}" # Use new version in release name | |
| 106 | draft: false | |
| 107 | prerelease: false | |
| 108 | env: | |
| 109 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Automatically provided token | |