Skip to content

Build and Release API Server #14

Build and Release API Server

Build and Release API Server #14

name: Build and Release API Server
on:
workflow_dispatch:
jobs:
build-and-release:
runs-on: windows-latest # Switched to Windows environment to use pre-installed .NET
if: github.actor != 'github-actions[bot]'
steps:
# Checkout the code
- uses: actions/checkout@v2
with:
persist-credentials: false # This prevents GitHub Actions from using its token
fetch-depth: 0 # This ensures all history is fetched
# Add this new step
- name: Configure NuGet to Use nuget.org
run: nuget sources Add -Name nuget.org -Source https://api.nuget.org/v3/index.json
# Restore project dependencies for Library
- name: Restore dependencies for Library
run: dotnet restore ./Library
# Restore project dependencies for API
- name: Restore dependencies for API
run: dotnet restore ./API
# Build the Azure Functions project
- name: Build Azure Functions project
run: |
cd API
dotnet publish -c Release -o publish
# Copy local.settings.json to build directory
- name: Copy local.settings.json to build directory
run: |
Copy-Item -Path API\local.settings.json -Destination API\publish\
# Zip the build output directly containing the build files
- name: Zip build output
run: |
cd API\publish
Compress-Archive -Path * -DestinationPath ..\..\VedAstro-API-Server.zip -Force
# Get shortened commit hash
- name: Get short commit hash
id: vars
run: |
$shortSha = "${{ github.sha }}"[0..6] -join ''
echo "SHORT_SHA=$shortSha" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
# Create Release and Upload Asset
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: VedAstro-API-Server.zip
tag_name: ${{ env.SHORT_SHA }}
name: API Server - ${{ env.SHORT_SHA }}
body: |
## 🔢 Steps to Run Server
1. **Download the `VedAstro-API-Server.zip`** file attached below.
2. **Extract** the contents of the zip file to a directory of your choice.
3. **Open a command prompt or terminal** and navigate to the extracted directory.
4. **Start the server** by running:
```bash
func start
```
5. **Get API link from [API Builder](https://vedastro.org/APIBuilder.html)** : Exp [http://localhost:7071/api/Calculate/AllPlanetData/PlanetName/](http://localhost:7071/api/Calculate/AllPlanetData/PlanetName/All/Location/Germany/Time/00:00/24/04/2024/+02:00)
6. 🎈 Enjoy the world's 1st open-source, non-profit Vedic astrology **API server**.
💌 Support the project --> **[vedastro.org/Donate.html](https://vedastro.org/Donate.html)**
------
_-You need [Azure Functions Core Tools](https://docs.microsoft.com/azure/azure-functions/functions-run-local) & [.NET SDK](https://dotnet.microsoft.com/en-us/download) installed._
_-Works on Windows, Linux & Mac_
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} # Automatically provided by GitHub Actions