Update overlay API endpoint for linked sensor data #119
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - dev | |
| jobs: | |
| build: | |
| name: Build and Release Artifacts | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # Required for creating releases | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| with: | |
| # fetch full history and tags so git describe and tag pushes work correctly | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: 1.21 | |
| - name: Set Version | |
| id: version | |
| run: | | |
| # On main use the VERSION file (fail if missing); on other branches, use 'dev' | |
| if [ "${{ github.ref }}" = "refs/heads/main" ]; then | |
| if [ -f VERSION ]; then | |
| echo "version=$(cat VERSION)" >> $GITHUB_ENV | |
| else | |
| echo "VERSION file is missing on main branch" >&2 | |
| exit 1 | |
| fi | |
| else | |
| echo "version=dev" >> $GITHUB_ENV | |
| fi | |
| - name: Print Version | |
| run: echo "Building version ${{ env.version }}" | |
| - name: Build Linux Binary | |
| run: | | |
| GOOS=linux GOARCH=amd64 go build -ldflags="-w -s -X main.version=${{ env.version }}" -o isley-linux | |
| - name: Build Windows Binary | |
| run: | | |
| GOOS=windows GOARCH=amd64 go build -ldflags="-w -s -X main.version=${{ env.version }}" -o isley.exe | |
| - name: Build Docker Image | |
| run: | | |
| docker build -t isley:${{ env.version }} . | |
| - name: Push Docker Image (Dev Branch Only) | |
| if: github.ref == 'refs/heads/dev' | |
| run: | | |
| # Push a stable dev tag and a short-sha specific dev tag so testers can pick the desired image | |
| echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | |
| SHORT_SHA=${GITHUB_SHA::8} | |
| docker tag isley:${{ env.version }} dwot/isley:dev | |
| docker tag isley:${{ env.version }} dwot/isley:dev-${SHORT_SHA} | |
| docker push dwot/isley:dev | |
| docker push dwot/isley:dev-${SHORT_SHA} | |
| - name: Push Docker Image (Main Branch Only) | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | |
| docker tag isley:${{ env.version }} dwot/isley:${{ env.version }} | |
| docker tag isley:${{ env.version }} dwot/isley:latest | |
| docker push dwot/isley:${{ env.version }} | |
| docker push dwot/isley:latest | |
| - name: Generate Release Notes | |
| id: release_notes | |
| run: | | |
| # Get the current date | |
| release_date=$(date -u +"%Y-%m-%d") | |
| echo "Release Date: $release_date" > release_notes.md | |
| # Determine a sensible commit range. Use commits since last tag if there is a tag, otherwise HEAD | |
| if git describe --tags --abbrev=0 >/dev/null 2>&1; then | |
| last_tag=$(git describe --tags --abbrev=0) | |
| commit_range="$last_tag..HEAD" | |
| else | |
| commit_range="HEAD" | |
| fi | |
| # Add commit messages | |
| echo -e "\n### Commits:\n" >> release_notes.md | |
| git log --pretty=format:"- %s (%h)" $commit_range >> release_notes.md | |
| # Escape multiline release notes for GITHUB_ENV | |
| escaped_notes=$(awk '{printf "%s\\n", $0}' release_notes.md) | |
| echo "release_notes=${escaped_notes}" >> $GITHUB_ENV | |
| - name: Create and push tag (Main Branch Only) | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| TAG="v${{ env.version }}" | |
| # If tag exists, skip creating it. Otherwise create annotated tag and push. | |
| if git rev-parse "$TAG" >/dev/null 2>&1; then | |
| echo "Tag $TAG already exists" | |
| else | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag -a "$TAG" -m "Release $TAG" | |
| git push origin "$TAG" | |
| fi | |
| - name: Release Artifacts (Main Branch Only) | |
| if: github.ref == 'refs/heads/main' | |
| uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 | |
| with: | |
| tag_name: v${{ env.version }} | |
| name: Release v${{ env.version }} | |
| body: ${{ env.release_notes }} | |
| files: | | |
| isley-linux | |
| isley.exe | |
| - name: Cleanup Release Notes | |
| run: rm -f release_notes.md |