add example #28
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build, Publish and Release | |
on: | |
push: | |
tags: | |
- v[0-9]+.[0-9]+.[0-9]+ | |
workflow_dispatch: | |
jobs: | |
Build_And_Publish: | |
name: 🎉 Build And Publish | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
# Login to GitHub Packages | |
- uses: docker/[email protected] | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Set Env Variables | |
run: | | |
echo "REPO_NAME=$(basename ${{ github.repository }})" >> $GITHUB_ENV | |
echo "REPO=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | |
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
echo ${{ env.REPO_NAME }} | |
echo ${{ env.REPO }} | |
echo ${{ env.TAG_NAME }} | |
# Build Docker image (multi-platform with Buildx) | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
push: true | |
tags: | | |
ghcr.io/${{ env.REPO }}/${{ env.REPO_NAME }}:latest | |
ghcr.io/${{ env.REPO }}/${{ env.REPO_NAME }}:${{ env.TAG_NAME }} | |
platforms: linux/arm/v7,linux/arm64/v8,linux/amd64 | |
Release: | |
runs-on: ubuntu-latest | |
name: 🚀 Release | |
needs: Build_And_Publish | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Install dependencies and build | |
run: | | |
npm ci | |
npm run build | |
- name: Dist dir to tar.gz | |
run: | | |
ls -la | |
tar -czvf dist.tar.gz dist | |
- name: Dist directory to zip | |
uses: montudor/action-zip@v1 | |
with: | |
args: | |
zip -qq -r dist.zip dist | |
- name: Get previous tag | |
id: previousTag | |
run: | | |
name=$(git --no-pager tag --sort=creatordate --merged ${{ github.ref_name }} | tail -2 | head -1) | |
echo "previousTag: $name" | |
echo "previousTag=$name" >> $GITHUB_ENV | |
- name: Generate CHANGELOG | |
id: changelog | |
uses: requarks/changelog-action@v1 | |
with: | |
token: ${{ github.token }} | |
fromTag: ${{ github.ref_name }} | |
toTag: ${{ env.previousTag }} | |
writeToFile: false | |
includeInvalidCommits: true | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ env.TAG_NAME }} | |
release_name: Release ${{ env.TAG_NAME }} | |
body: | | |
To know more about this release, please refer to the README. | |
**Changelog:** | |
${{ steps.changelog.outputs.changes }} | |
draft: false | |
prerelease: false | |
files: | | |
dist.tar.gz | |
dist.zip |