Files
wanderer/.github/workflows/release.yaml

96 lines
3.0 KiB
YAML

name: Publish Release
on:
pull_request:
types: [closed]
branches: [main]
jobs:
# Only run if the PR was merged AND it came from a release branch
publish:
if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/v')
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set Version Output
id: get_version
run: |
# Extract v0.12.0 from release/v0.12.0
VERSION_TAG=${GITHUB_HEAD_REF#release/}
echo "version=$VERSION_TAG" >> $GITHUB_OUTPUT
# Git Tagging
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag $VERSION_TAG
git push origin $VERSION_TAG
docker-build:
needs: publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: '1.22'
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '22'
- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build Docker Images
env:
VERSION: ${{ needs.publish.outputs.version }}
run: |
docker buildx build db/ --no-cache -t flomp/wanderer-db:$VERSION -t flomp/wanderer-db:latest --platform=linux/amd64,linux/arm64 --push
docker buildx build web/ --no-cache -t flomp/wanderer-web:$VERSION -t flomp/wanderer-web:latest --platform=linux/amd64,linux/arm64 --push
npm --prefix docs ci
npm --prefix docs run build
docker buildx build ./docs --no-cache -t flomp/wanderer-docs:$VERSION -t flomp/wanderer-docs:latest --platform=linux/amd64,linux/arm64 --push
release:
needs: [publish, docker-build]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- name: Extract release notes
id: changelog
run: |
VERSION="${{ needs.publish.outputs.version }}"
# Clean 'v' from v0.12.0 for awk if your changelog uses 0.12.0
RAW_VER=${VERSION#v}
CHANGELOG=$(awk -v ver="$RAW_VER" 'BEGIN {in_section=0} /^# / {if (in_section) exit; if ($2 == ver) in_section=1} in_section {print}' CHANGELOG.md)
echo 'changelog<<EOF' >> $GITHUB_OUTPUT
printf "$CHANGELOG" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.publish.outputs.version }}
body: ${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false