-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from Alirezaja1384/build-workflow
Build workflow
- Loading branch information
Showing
1 changed file
with
82 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: Bump version, build and release | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
tag: | ||
name: Tag and release | ||
runs-on: ubuntu-latest | ||
outputs: | ||
new_tag: ${{ steps.tag_version.outputs.new_tag }} | ||
new_version: ${{ steps.tag_version.outputs.new_version }} | ||
changelog: ${{ steps.tag_version.outputs.changelog }} | ||
|
||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Bump version and push tag | ||
id: tag_version | ||
uses: mathieudutour/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
default_bump: patch | ||
|
||
- name: Create a GitHub release | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
tag: ${{ steps.tag_version.outputs.new_tag }} | ||
name: Release ${{ steps.tag_version.outputs.new_tag }} | ||
body: ${{ steps.tag_version.outputs.changelog }} | ||
|
||
build: | ||
name: Build and push | ||
runs-on: ubuntu-latest | ||
needs: tag | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Metadata extraction | ||
id: metadata | ||
uses: docker/metadata-action@v5 | ||
with: | ||
# List of Docker images to use as base name for tags | ||
images: | | ||
ghcr.io/${{ github.repository }} | ||
# Generates Docker tags based on the following events/attributes | ||
tags: | | ||
type=raw,value=${{ needs.tag.outputs.new_tag }} | ||
type=raw,value=${{ needs.tag.outputs.new_version }} | ||
type=sha | ||
latest | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v3 | ||
with: | ||
push: true | ||
tags: ${{ steps.metadata.outputs.tags }} | ||
labels: ${{ steps.metadata.outputs.labels }} |