feat: create first forgejo release
Some checks failed
Release / release (push) Failing after 14m14s

This commit is contained in:
Adriano Caloiaro 2026-07-19 12:45:53 -06:00
parent 8578516985
commit e443565fee
No known key found for this signature in database

View file

@ -0,0 +1,86 @@
name: Release
on:
push:
branches:
- main
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: https://github.com/cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Detect version bump
id: ver
shell: bash -c "nix develop --impure -c bash -- {0}"
run: |
OLD=$(svu current --strip-prefix)
NEW=$(svu next --strip-prefix)
if [ "$OLD" = "$NEW" ]; then
echo "bump=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "bump=true" >> "$GITHUB_OUTPUT"
echo "old=$OLD" >> "$GITHUB_OUTPUT"
echo "new=$NEW" >> "$GITHUB_OUTPUT"
- name: Bump version files and generate changelog
if: steps.ver.outputs.bump == 'true'
shell: bash -c "nix develop --impure -c bash -- {0}"
run: |
git config user.email "actions@code.adriano.fyi"
git config user.name "Forgejo Actions"
sed -i "s/${{ steps.ver.outputs.old }}/${{ steps.ver.outputs.new }}/g" default.nix main.go
git-chglog --next-tag="v${{ steps.ver.outputs.new }}" > CHANGELOG.md
git-chglog --next-tag="v${{ steps.ver.outputs.new }}" "v${{ steps.ver.outputs.new }}" > /tmp/release-notes.md
git add default.nix main.go CHANGELOG.md
git commit -m "bump di-tui version"
- name: Build binaries
if: steps.ver.outputs.bump == 'true'
shell: bash -c "nix develop --impure -c bash -- {0}"
run: |
for target in linux/amd64 linux/arm64 darwin/amd64 darwin/arm64; do
os=$(dirname "$target")
arch=$(basename "$target")
CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -o "di-tui-${os}-${arch}" main.go
done
- name: Push commit and tag
if: steps.ver.outputs.bump == 'true'
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="v${{ steps.ver.outputs.new }}"
git remote set-url origin "https://oauth2:${TOKEN}@code.adriano.fyi/me/di-tui.git"
git push
git tag "$VERSION"
git push origin "$VERSION"
- name: Create release and upload assets
if: steps.ver.outputs.bump == 'true'
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="v${{ steps.ver.outputs.new }}"
RELEASE_ID=$(curl -sf -X POST \
-H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/json" \
"https://code.adriano.fyi/api/v1/repos/me/di-tui/releases" \
-d "{\"tag_name\":\"${VERSION}\",\"name\":\"${VERSION}\",\"body\":$(jq -Rs . /tmp/release-notes.md)}" \
| jq -r .id)
for binary in di-tui-linux-amd64 di-tui-linux-arm64 di-tui-darwin-amd64 di-tui-darwin-arm64; do
curl --fail-with-body -X POST \
-H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/octet-stream" \
--data-binary "@./${binary}" \
"https://code.adriano.fyi/api/v1/repos/me/di-tui/releases/${RELEASE_ID}/assets?name=${binary}"
done