Skip to content

Release

Release #167

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag'
required: false
schedule:
- cron: '0 19 * * *'
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout GoToSocial
uses: actions/checkout@v4
with:
repository: superseriousbusiness/gotosocial
path: gotosocial
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 'stable'
check-latest: true
- name: Get Tag
run: |
if [ -z "${{ github.event.inputs.tag }}" ]; then
export TAG=$(git -C gotosocial -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' | tail -n1 | cut --delimiter='/' --fields=3)
else
export TAG=${{ github.event.inputs.tag }}
fi
echo "TAG=$TAG" >> $GITHUB_ENV
if [[ $TAG == *"rc"* || $TAG == *"beta"* || $TAG == *"alpha"* ]]; then
export PRERELEASE=true
else
export PRERELEASE=false
fi
echo "PRERELEASE=$PRERELEASE" >> $GITHUB_ENV
- name: Clean Temporary Files
run: |
rm -rf gotosocial
rm -rf client models
- name: Generate Client
id: generate-client
run: |
export CURRENT_LATEST=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.tag_name')
if [ "$CURRENT_LATEST" == "$TAG" ]; then
echo "No need to generate client for Tag: $TAG"
exit 0
fi
export LATEST_PRERELEASE=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases | jq -r '.[].tag_name' | grep -E 'rc|beta|alpha' | sort -r | head -n 1)
if [ "$TAG" == "$LATEST_PRERELEASE" ]; then
echo "No need to generate client for Tag: $TAG"
exit 0
fi
echo "Generating Client for Tag: $TAG"
git checkout -b "release/${TAG}"
go get github.com/go-swagger/go-swagger/cmd/swagger
go run github.com/go-swagger/go-swagger/cmd/swagger generate client --spec https://raw.githubusercontent.com/superseriousbusiness/gotosocial/${TAG}/docs/api/swagger.yaml
patch -u -p1 -i patches/filter-context.diff
echo "generated=true" >> $GITHUB_OUTPUT
- name: Go Mod Tidy
run: go mod tidy
- name: Commit
if: steps.generate-client.outputs.generated == 'true'
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "bump version to ${{ env.TAG }}"
branch: "release/${{ env.TAG }}"
- name: Push
if: steps.generate-client.outputs.generated == 'true'
run: git push origin "release/${{ env.TAG }}"
- name: Release
if: steps.generate-client.outputs.generated == 'true'
uses: softprops/action-gh-release@v2
with:
body: "Bump version to ${{ env.TAG }}"
tag_name: ${{ env.TAG }}
target_commitish: "release/${{ env.TAG }}"
prerelease: ${{ env.PRERELEASE }}
- name: Remove Temporary Branch
if: steps.generate-client.outputs.generated == 'true'
run: git push origin --delete "release/${{ env.TAG }}"