Skip to content

Commit

Permalink
ci: create tag and release Docker image (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtyr authored Jan 28, 2022
1 parent 35c1ee9 commit eed698b
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Docker release

on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+

env:
REGISTRY: ghcr.io
IMAGE_NAME: smee.io

jobs:
image:
name: Build and push Docker image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Check out the repo
uses: actions/checkout@v2

- run: echo ${{ github.actor }}

- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
35 changes: 35 additions & 0 deletions .github/workflows/tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Create tag

on:
pull_request:
branches:
- master
types:
- closed
paths-ignore:
- LICENSE
- README.md
- .github/**
- .*

permissions:
contents: read
packages: read

jobs:
tag:
name: Tagging
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Create new tag
id: version
run: |
LAST_TAG=$(git tag --sort=creatordate --sort=v:refname | tail -n1)
NEW_TAG=$(echo "$LAST_TAG" | awk '{split(substr($0, 2), a, "."); printf "v%d.%d.%d", a[1], a[2], a[3]+1}')
git tag $NEW_TAG
git push --tags

0 comments on commit eed698b

Please sign in to comment.