Skip to content

feat: add test code #13

feat: add test code

feat: add test code #13

Workflow file for this run

name: Release
on:
push:
branches:
- main
jobs:
test:
uses: ./.github/workflows/test.yml
get-version:
needs: test
runs-on: ubuntu-latest
outputs:
current: ${{ steps.current.outputs.version }}
previous: ${{ steps.previous.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- id: current
run: |
VERSION=$(jq -r '.version' package.json)
echo "current: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- id: previous
run: |
VERSION=$(git show HEAD~1:package.json | jq -r '.version')
echo "previous: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
release:
runs-on: ubuntu-latest
needs: get-version
if: ${{ needs.get-version.outputs.current != needs.get-version.outputs.previous }}
steps:
- uses: actions/checkout@v4
- name: Add Tag
run: |
git tag "v${{ needs.get-version.outputs.current }}"
git push origin "v${{ needs.get-version.outputs.current }}"
- name: Create Release to GitHub
run: gh release create "v${{ needs.get-version.outputs.current }}" --generate-notes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-and-publish:
runs-on: ubuntu-latest
needs: get-version
if: ${{ needs.get-version.outputs.current != needs.get-version.outputs.previous }}
steps:
- name: checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ github.repository }}
tags: |
type=raw,value=latest
type=raw,value=v${{ needs.get-version.outputs.current }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- uses: sarisia/actions-status-discord@v1
if: always()
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
deploy-webhook:
runs-on: ubuntu-latest
needs: build-and-publish
steps:
- env:
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }}
run: |
TIMESTAMP=$(date +%s)
SIGNATURE=$(echo -n "$TIMESTAMP" | openssl dgst -sha256 -hmac "$WEBHOOK_SECRET" | awk '{print $2}')
curl -X POST "$WEBHOOK_URL" \
-H "X-Signature: $SIGNATURE" \
-H "X-Timestamp: $TIMESTAMP"