Skip to content

feat: display counties instead of coordinates #83

feat: display counties instead of coordinates

feat: display counties instead of coordinates #83

Workflow file for this run

name: Build and Test/Release
on:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- "*"
tags:
- "v*"
env:
OBSERVER_BUILD_CHANNEL: github-actions-ci
CLOUDFLARE_RECORD_NAME: observer.updates.anyshake.org
jobs:
build_web:
runs-on: ubuntu-latest
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "latest"
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Build web
working-directory: web/src
run: |
npm ci
npm run build
tar -zcf ../web_dist.tar.gz ../dist
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: web-dist
path: web/web_dist.tar.gz
build_core:
runs-on: ubuntu-latest
strategy:
matrix:
target_id:
- android_arm64_v8a
- darwin_amd64
- darwin_arm64_v8a
- freebsd_386
- freebsd_amd64
- freebsd_arm32_v5
- freebsd_arm32_v6
- freebsd_arm32_v7a
- freebsd_arm64_v8a
- linux_386
- linux_amd64
- linux_arm32_v5
- linux_arm32_v6
- linux_arm32_v7a
- linux_arm64_v8a
- linux_loong64
- linux_mips
- linux_mips_softfloat
- linux_mips64
- linux_mips64_softfloat
- linux_mips64le
- linux_mips64le_softfloat
- linux_mipsle
- linux_mipsle_softfloat
- linux_ppc64le
- linux_riscv64
- linux_s390x
- openbsd_386
- openbsd_amd64
- openbsd_arm32_v5
- openbsd_arm32_v6
- openbsd_arm32_v7a
- openbsd_arm64_v8a
- windows_386
- windows_amd64
- windows_arm64_v8a
- windows7_386
- windows7_amd64
fail-fast: true
needs:
- build_web
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup workflow env
run: |
GOOS=$(jq ".[\"${{ matrix.target_id }}\"].goos" -r < pkg/unibuild/map.json)
echo "GOOS=$GOOS" >> $GITHUB_ENV
GOARCH=$(jq ".[\"${{ matrix.target_id }}\"].goarch" -r < pkg/unibuild/map.json)
echo "GOARCH=$GOARCH" >> $GITHUB_ENV
GOARM=$(jq ".[\"${{ matrix.target_id }}\"].goarm" -r < pkg/unibuild/map.json)
echo "GOARM=$GOARM" >> $GITHUB_ENV
GOMIPS=$(jq ".[\"${{ matrix.target_id }}\"].gomips" -r < pkg/unibuild/map.json)
echo "GOMIPS=$GOMIPS" >> $GITHUB_ENV
RELEASE_NAME=$(jq ".[\"${{ matrix.target_id }}\"].name" -r < pkg/unibuild/map.json)
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV
- name: Setup Go toolchain
if: ${{ matrix.target_id != 'windows7_386' && matrix.target_id != 'windows7_amd64' }}
uses: actions/setup-go@v5
with:
cache: false
go-version: "stable"
check-latest: true
- name: Setup Go toolchain (Windows 7)
if: ${{ matrix.target_id == 'windows7_386' || matrix.target_id == 'windows7_amd64'}}
run: |
curl -L -o /tmp/go-legacy-win7.tar.gz https://github.com/thongtech/go-legacy-win7/releases/download/v1.24.2-1/go-legacy-win7-1.24.2-1.linux_amd64.tar.gz
tar -xvf /tmp/go-legacy-win7.tar.gz -C $HOME
rm -f go-legacy-win7.tar.gz
export GOROOT=$HOME/go-legacy-win7
echo "GOROOT=$GOROOT" >> $GITHUB_ENV
$GOROOT/bin/go version
- name: Download web artifacts
uses: actions/download-artifact@v4
with:
name: web-dist
path: web
- name: Extract web artifacts
working-directory: web
run: |
tar -zxf web_dist.tar.gz
rm -f web_dist.tar.gz
- name: Mark as pre-release
if: ${{ ! startsWith(github.ref, 'refs/tags/') }}
run: |
echo "SNAPSHOT_TAG=snapshot" >> $GITHUB_ENV
- name: Build core application
run: |
if [[ "${{ matrix.target_id }}" == "windows7_386" || "${{ matrix.target_id }}" == "windows7_amd64" ]]; then
GOBIN=${{ env.GOROOT }}/bin/go
else
GOBIN=go
fi
GO=$GOBIN \
GOOS=${{ env.GOOS }} \
GOARCH=${{ env.GOARCH }} \
GOARM=${{ env.GOARM }} \
GOMIPS=${{ env.GOMIPS }} \
BUILD_CHANNEL=${{ env.OBSERVER_BUILD_CHANNEL }} \
BUILD_TOOLCHAIN=${{ matrix.target_id }} \
VERSION_PRE_RELEASE=${{ env.SNAPSHOT_TAG }} \
make build
- name: Create release digest
run: |
make digest | tee build/${{ matrix.target_id }}.dgst
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target_id }}
path: build/dist/*
- name: Package release
if: ${{ startsWith(github.ref, 'refs/tags/') }}
working-directory: build/dist
run: |
zip -r ../${{ matrix.target_id }}.zip *
- name: Create release note
if: ${{ startsWith(github.ref, 'refs/tags/') }}
id: release_note
uses: mikepenz/release-changelog-builder-action@v5
with:
mode: "COMMIT"
configurationJson: |
{
"template":"#{{CHANGELOG}}\n\nThis release note is automatically generated by GitHub Actions, please refer to [CHANGELOG.md](https://github.com/anyshake/observer/blob/master/CHANGELOG.md) for details.",
"categories":[
{
"title":"## Breaking Changes",
"labels":[
"break",
"major",
"incompatible"
]
},
{
"title":"## New Features",
"labels":[
"feat",
"feature"
]
},
{
"title":"## Bug Fixes",
"labels":[
"fix",
"bug"
]
},
{
"title": "## CI/CD Changes",
"labels": [
"build",
"ci",
"test"
]
},
{
"title":"## Dependency Updates",
"labels": [
"deps",
"dependencies",
"dependency"
]
},
{
"title": "## Chore",
"labels": [
"chore",
"docs",
"perf"
]
},
{
"title": "## Refactor",
"labels": [
"refactor",
"revert",
"style"
]
}
],
"label_extractor":[
{
"pattern":"^(break|major|incompatible|feat|feature|fix|bug|build|ci|test|deps|dependencies|dependency|chore|docs|perf|refactor|revert|style){1}(\\([\\w\\-\\.]+\\))?(!)?: ([\\w ])+([\\s\\S]*)",
"target":"$1"
}
]
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload to GitHub Release
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: build/${{ matrix.target_id }}*
tag: ${{ github.ref }}
file_glob: true
overwrite: true
body: ${{ steps.release_note.outputs.changelog }}
sync_version:
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/') }}
needs:
- build_web
- build_core
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Generate version metadata
id: version
run: |
VERSION_DATA=$(make version)
echo $VERSION_DATA
echo VERSION_DATA=$VERSION_DATA >> $GITHUB_ENV
- name: Update DNS record
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_DNS_ZONE_ID: ${{ secrets.CLOUDFLARE_DNS_ZONE_ID }}
run: |
CLOUDFLARE_DNS_RECORD_ID=$(curl -X GET "https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_DNS_ZONE_ID/dns_records?type=TXT&name=$CLOUDFLARE_RECORD_NAME" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
-s \
| \
jq -r '.result[0].id')
echo "Got Cloudflare DNS record ID: $CLOUDFLARE_DNS_RECORD_ID"
curl -X PATCH https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_DNS_ZONE_ID/dns_records/$CLOUDFLARE_DNS_RECORD_ID \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
-d '{
"name": '"\"$CLOUDFLARE_RECORD_NAME\""',
"ttl": 60,
"type": "TXT",
"comment": "updated at '"$(date -u "+%Y-%m-%d %H:%M:%S")"'",
"content": '"\"$VERSION_DATA\""'
}' | jq .