243 lines
7.9 KiB
YAML
243 lines
7.9 KiB
YAML
name: Release
|
|
on:
|
|
schedule:
|
|
- cron: "0 9 * * 0"
|
|
issue_comment:
|
|
types: [created]
|
|
|
|
jobs:
|
|
check_manual_trigger:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Log event metadata
|
|
run: |
|
|
echo "Issue: ${{ gitea.event.issue.number }}"
|
|
echo "Comment: ${{ gitea.event.comment.body }}"
|
|
echo "User: ${{ gitea.event.comment.user.login }}"
|
|
|
|
- name: Stop workflow if required conditions are not met
|
|
if: ${{ !contains(gitea.event.issue.number, '436') || !contains(gitea.event.comment.body, '/trigger-release') || !contains(gitea.event.comment.user.login, 'luke') }}
|
|
run: exit 1
|
|
|
|
- name: Delete issue comment
|
|
run: |
|
|
curl -X DELETE -H "Authorization: token ${{ gitea.token }}" "${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/issues/comments/${{ gitea.event.comment.id }}"
|
|
|
|
get_latest_tag:
|
|
name: Get latest tag
|
|
runs-on: ubuntu-latest
|
|
needs: check_manual_trigger
|
|
outputs:
|
|
latesttag: ${{ steps.latesttag.outputs.latesttag }}
|
|
steps:
|
|
- uses: actions/checkout@v4.1.7
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Get latest tag
|
|
id: latesttag
|
|
run: |
|
|
LATESTTAG=$(git describe --tags --abbrev=0)
|
|
echo "latesttag=$LATESTTAG" >> "$GITEA_OUTPUT"
|
|
|
|
test:
|
|
name: Unit Test
|
|
needs: get_latest_tag
|
|
uses: https://git.tainton.uk/public/webexmemebot/.gitea/workflows/ci.yml@${{ needs.get_latest_tag.outputs.latesttag }}
|
|
continue-on-error: true
|
|
|
|
create_release:
|
|
name: Create Release
|
|
runs-on: ubuntu-latest
|
|
# needs: test
|
|
outputs:
|
|
release_name: ${{ steps.tag_version.outputs.new_tag }}
|
|
success: ${{ steps.set_flag.outputs.success }}
|
|
# srvurl: ${{ steps.set_srvurl.outputs.srvurl }}
|
|
steps:
|
|
- uses: actions/checkout@v4.1.7
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Changes since last tag
|
|
id: changes
|
|
run: |
|
|
CHANGES=$(git log $(git describe --tags --abbrev=0)..HEAD --no-merges --oneline)
|
|
echo "$CHANGES"
|
|
$CHANGES_FEAT=$(echo "$CHANGES" | grep -i "feat")
|
|
$CHANGES_FIX=$(echo "$CHANGES" | grep -i "fix")
|
|
$CHANGES_DEP=$(echo "$CHANGES" | grep -i "dependencies")
|
|
$CHANGES_OTHER=$(echo "$CHANGES" | grep -i "other")
|
|
if [ -z "$CHANGES" ]
|
|
then
|
|
echo "changes=false" >> "$GITEA_OUTPUT"
|
|
echo "changes_feat=false" >> "$GITEA_OUTPUT"
|
|
echo "changes_fix=false" >> "$GITEA_OUTPUT"
|
|
echo "changes_dep=false" >> "$GITEA_OUTPUT"
|
|
echo "changes_other=false" >> "$GITEA_OUTPUT"
|
|
else
|
|
echo "changes=true" >> "$GITEA_OUTPUT"
|
|
echo "changes_feat=CHANGES_FEAT" >> "$GITEA_OUTPUT"
|
|
echo "changes_fix=CHANGES_FIX" >> "$GITEA_OUTPUT"
|
|
echo "changes_dep=CHANGES_DEP" >> "$GITEA_OUTPUT"
|
|
echo "changes_other=CHANGES_OTHER" >> "$GITEA_OUTPUT"
|
|
fi
|
|
|
|
- name: Create changelog
|
|
id: create_changelog
|
|
run: |
|
|
if test "${{ steps.changes.outputs.changes }}" = "true"
|
|
then
|
|
cat <<EOF >> changelog.md
|
|
## 🚀 Features
|
|
$CHANGES_FEAT
|
|
|
|
## 🐛 Bug Fixes
|
|
$CHANGES_FIX
|
|
|
|
## 📦 Dependencies
|
|
$CHANGES_DEP
|
|
|
|
## 💬 Other
|
|
$CHANGES_OTHER
|
|
EOF
|
|
fi
|
|
|
|
- name: Set server URL
|
|
id: set_srvurl
|
|
run: |
|
|
SRVURL=$(echo "${{ gitea.server_url }}" | sed 's/https:\/\/\(.*\)/\1/')
|
|
echo "srvurl=$SRVURL" >> "$GITEA_OUTPUT"
|
|
|
|
- name: Get next version
|
|
uses: TriPSs/conventional-changelog-action@v6
|
|
id: get_next_version
|
|
with:
|
|
git-url: ${{ steps.set_srvurl.outputs.srvurl }}
|
|
github-token: ${{ gitea.token }}
|
|
skip-commit: true
|
|
release-count: 1
|
|
output-file: false
|
|
create-summary: true
|
|
skip-on-empty: true
|
|
skip-version-file: true
|
|
skip-tag: true
|
|
|
|
# - name: Bump version and push tag
|
|
# id: tag_version
|
|
# if: steps.changes.outputs.changes == 'true'
|
|
# uses: mathieudutour/github-tag-action@v6.2
|
|
# with:
|
|
# github_token: ${{ gitea.token }}
|
|
# default_bump: minor
|
|
# # default_bump: false
|
|
|
|
# - name: Build Changelog
|
|
# uses: mikepenz/release-changelog-builder-action@v4
|
|
# id: build_changelog
|
|
# env:
|
|
# GITHUB_TOKEN: ${{ gitea.token }}
|
|
# with:
|
|
# platform: "gitea"
|
|
# configurationJson: |
|
|
# {
|
|
# "pr_template": "- #{{TITLE}} ([##{{NUMBER}}](#{{URL}}))",
|
|
# "empty_template": "- no changes",
|
|
# "categories": [
|
|
# {
|
|
# "title": "## 💬 Other",
|
|
# "labels": ["type/other"]
|
|
# },
|
|
# {
|
|
# "title": "## 📦 Dependencies",
|
|
# "labels": ["type/dependencies"]
|
|
# },
|
|
# {
|
|
# "title": "## 🚀 Features",
|
|
# "labels": ["type/feature"]
|
|
# },
|
|
# {
|
|
# "title": "## 🐛 Bug Fixes",
|
|
# "labels": ["type/bugfix"]
|
|
# },
|
|
# ]
|
|
# }
|
|
|
|
- name: Create release
|
|
id: create_release
|
|
uses: akkuman/gitea-release-action@v1
|
|
env:
|
|
NODE_OPTIONS: '--experimental-fetch' # if nodejs < 18
|
|
with:
|
|
tag: ${{ steps.get_next_version.outputs.tag }}
|
|
name: ${{ steps.get_next_version.outputs.tag }}
|
|
body_path: changelog.md
|
|
|
|
- name: Set success/fail flag
|
|
id: set_flag
|
|
if: steps.changes.outputs.changes == 'true'
|
|
run: if test "${{ steps.changes.outputs.changes }}" = "true"; then echo "success=true" >> "$GITHUB_OUTPUT"; else echo "success=false" >> "$GITHUB_OUTPUT"; fi
|
|
|
|
create_docker:
|
|
name: Create Docker Image
|
|
needs: create_release
|
|
if: ${{ needs.create_release.outputs.success == 'true' }}
|
|
outputs:
|
|
success: ${{ steps.set_flag.outputs.success }}
|
|
with:
|
|
release: ${{ needs.create_release.outputs.release_name }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ inputs.release }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to Gitea Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: git.tainton.uk
|
|
username: ${{ gitea.actor }}
|
|
password: ${{ gitea.token }}
|
|
|
|
- name: Log in to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: luketainton
|
|
password: ${{ secrets.GHCR_TOKEN }}
|
|
|
|
- name: Extract metadata (tags, labels) for Docker
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: |
|
|
git.tainton.uk/${{ gitea.repository }}
|
|
ghcr.io/luketainton/webexmemebot
|
|
tags: |
|
|
type=semver,pattern=v{{version}},value=${{ inputs.release }}
|
|
|
|
- name: Build and push Docker image
|
|
id: push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: true
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
tags: |
|
|
git.tainton.uk/${{ gitea.repository }}:latest
|
|
git.tainton.uk/${{ gitea.repository }}:${{ inputs.release }}
|
|
ghcr.io/luketainton/webexmemebot:latest
|
|
ghcr.io/luketainton/webexmemebot:${{ inputs.release }}
|
|
|
|
- name: Generate artifact attestation
|
|
uses: actions/attest-build-provenance@v2
|
|
with:
|
|
subject-name: ghcr.io/luketainton/webexmemebot
|
|
subject-digest: ${{ steps.push.outputs.digest }}
|
|
push-to-registry: true
|
|
|
|
- name: Set success flag
|
|
id: set_flag
|
|
run: echo "success=true" >> "$GITHUB_OUTPUT"
|