Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBoatyMcBoatFace committed Aug 30, 2023
1 parent 1fabe1f commit 4792577
Show file tree
Hide file tree
Showing 3 changed files with 154 additions and 0 deletions.
92 changes: 92 additions & 0 deletions .github/workflows/auto-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# .github/workflows/auto-version.yml
# Resources:
# https://github.com/marketplace/actions/git-semantic-version#git-based-semantic-versioning
# https://github.com/marketplace/actions/sentry-release
# https://github.com/marketplace/actions/create-release
# Auto-generates version for commits

name: Auto Versioning and Release

on:
push:
branches:
- main
paths-ignore:
- 'assets/**'
- '.github/**'

jobs:
versioning:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all history and tags

- name: Generate Semantic Version
id: version
uses: PaulHatch/semantic-version@v5.0.3
with:
tag_prefix: "v"
major_pattern: "(MAJOR)"
minor_pattern: "(MINOR)"
# Additional parms here...

- name: Print new version
run: echo "New version is ${{ steps.version.outputs.version }}"

- name: Configure Git user
run: |
git config user.name "${{ secrets.BOT_NAME }}"
git config user.email "${{ secrets.BOT_EMAIL }}"
- name: Tag the new version
run: |
git tag v${{ steps.version.outputs.version }}
git push origin v${{ steps.version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}

outputs:
version: ${{ steps.version.outputs.version }}

create-release:
needs: versioning
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Create Release
uses: ncipollo/release-action@v1.12.0
with:
artifacts: "" # You can specify the artifacts to upload here
body: "Auto-generated release from v${{ needs.versioning.outputs.version }}"
name: "Release v${{ needs.versioning.outputs.version }}"
tag: "v${{ needs.versioning.outputs.version }}"
token: ${{ secrets.BOT_TOKEN }}

configure-sentry:
needs: create-release
name: Configure Sentry
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Create Sentry release
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
SENTRY_URL: ${{ secrets.SENTRY_URL }}
with:
environment: production
62 changes: 62 additions & 0 deletions .github/workflows/containerize.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: 🏗️📤 Build and publish 🐳 images

on:
push:

env:
GHCR_REGISTRY: ghcr.io
DOCKERHUB_REGISTRY: docker.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
name: 🏗️📤 Build and push 🐳 image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: 👀📦 Checkout repository.
uses: actions/checkout@v3

- name: 🔑📦 Login to GitHub Container Registry
uses: docker/login-action@v2.1.0
with:
registry: ${{ env.GHCR_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: 🔑📦 Login to Docker Hub
uses: docker/login-action@v2.1.0
with:
registry: ${{ env.DOCKERHUB_REGISTRY }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract metadata (🏷️, 🏷️) for 🐳
id: meta
uses: docker/metadata-action@v4.3.0
with:
flavor: |
latest=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
images: |
${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}
${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,priority=100,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
type=raw,value=${{ env.RELEASE_VERSION }},priority=500,enable=${{ env.RELEASE_VERSION != '' }}
type=sha,enable=true,prefix=main-,suffix=,format=short,priority=200,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
type=raw,prefix={{branch}}-,value=,priority=300,enable=${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }}
type=sha,enable=true,prefix={{branch}}-,suffix=,format=short,priority=400,enable=${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }}
# Caching | https://docs.docker.com/build/ci/github-actions/cache/
- name: 🏗️📤 Build and push 🐳 image
uses: docker/build-push-action@v2.7.0
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# cache-from: type=gha
# cache-to: type=gha,mode=max
Empty file added LICENSE
Empty file.

0 comments on commit 4792577

Please sign in to comment.