65 lines
2.1 KiB
YAML
65 lines
2.1 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-gitea
|
|
|
|
steps:
|
|
|
|
- name: Prep For Local Builds
|
|
run: echo "${LOCIP} gitea.comnenos" >> /etc/hosts
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install Build Tools
|
|
run: |
|
|
apt update
|
|
apt -y --no-install-recommends install build-essential gcc make
|
|
|
|
- name: Build
|
|
run: make all
|
|
|
|
- name: Create Release Archive
|
|
run: |
|
|
VERSION=${GITHUB_REF#refs/tags/}
|
|
mkdir -p release
|
|
tar -czf release/cnotes-${VERSION}-linux-amd64.tar.gz -C build cnadd cndump cncount cndel cnfind cnhelp
|
|
cd release
|
|
sha256sum cnotes-${VERSION}-linux-amd64.tar.gz > cnotes-${VERSION}-linux-amd64.tar.gz.sha256
|
|
ls cnotes-${VERSION}-linux-amd64.tar.gz* # For debugging
|
|
|
|
- name: Create Release
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
|
run: |
|
|
VERSION=${GITHUB_REF#refs/tags/}
|
|
|
|
# Create release
|
|
curl -X POST "https://repos.gmgauthier.com/api/v1/repos/${GITHUB_REPOSITORY}/releases" \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{
|
|
\"tag_name\": \"${VERSION}\",
|
|
\"name\": \"cnotes ${VERSION}\",
|
|
\"body\": \"Release ${VERSION}\"
|
|
}" > release_response.json
|
|
|
|
RELEASE_ID=$(cat release_response.json | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
|
|
|
|
# Upload tarball
|
|
curl -X POST "https://repos.gmgauthier.com/api/v1/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=cnotes-${VERSION}-linux-amd64.tar.gz" \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-H "Content-Type: application/gzip" \
|
|
--data-binary @release/cnotes-${VERSION}-linux-amd64.tar.gz
|
|
|
|
# Upload checksum
|
|
curl -X POST "https://repos.gmgauthier.com/api/v1/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=cnotes-${VERSION}-linux-amd64.tar.gz.sha256" \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-H "Content-Type: text/plain" \
|
|
--data-binary @release/cnotes-${VERSION}-linux-amd64.tar.gz.sha256
|