feat: add release-please, change versioning to SemVer
This commit is contained in:
parent
914dbd3c1f
commit
67c85f314d
6 changed files with 173 additions and 94 deletions
|
|
@ -1,17 +1,14 @@
|
|||
name: Perform linting and run tests
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
branches-ignore: ["master"]
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
workflow_dispatch:
|
||||
branches: ["master"]
|
||||
|
||||
jobs:
|
||||
build-and-test:
|
||||
name: Build, Lint, and Test
|
||||
test:
|
||||
name: Lint and Test
|
||||
runs-on: ubuntu-latest
|
||||
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
|
||||
env:
|
||||
86
.github/workflows/docker_release.yml
vendored
86
.github/workflows/docker_release.yml
vendored
|
|
@ -1,86 +0,0 @@
|
|||
name: Docker Release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
platforms:
|
||||
type: choice
|
||||
description: 'Build Platforms'
|
||||
required: true
|
||||
default: 'linux/amd64'
|
||||
options:
|
||||
- 'linux/amd64'
|
||||
- 'linux/amd64,linux/arm64'
|
||||
docker_tags:
|
||||
type: string
|
||||
description: 'Docker Tags'
|
||||
required: true
|
||||
default: 'dev'
|
||||
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
|
||||
jobs:
|
||||
build_and_push_docker:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
dev_arch: 'linux/amd64'
|
||||
release_arch: 'linux/amd64,linux/arm64'
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
docker.io/communitymaintained/pinchflat
|
||||
ghcr.io/${{ github.repository }}
|
||||
# All non-release actions will be tagged as `dev` (ie: push, workflow_dispatch)
|
||||
tags: |
|
||||
type=ref,event=tag
|
||||
type=raw,value=dev,enable=${{ github.event_name != 'release' && github.event_name != 'workflow_dispatch' }}
|
||||
type=raw,value=${{ inputs.docker_tags }},enable=${{ github.event_name == 'workflow_dispatch' }}
|
||||
flavor: |
|
||||
latest=auto
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and Push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: ./docker/selfhosted.Dockerfile
|
||||
# If the event is a release, use the release_arch, otherwise use the
|
||||
# platforms input if present, falling back to dev_arch
|
||||
platforms: ${{ github.event_name == 'release' && env.release_arch || (github.event.inputs.platforms || env.dev_arch) }}
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
157
.github/workflows/release-please.yml
vendored
Normal file
157
.github/workflows/release-please.yml
vendored
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
name: Release Please
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["master"]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Lint and Test
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
COMPOSE_FILE: ./docker-compose.ci.yml
|
||||
MIX_ENV: test
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Pull prebuilt images
|
||||
run: docker compose pull
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build docker image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: ./docker/dev.Dockerfile
|
||||
load: true
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
- name: Run Docker image
|
||||
run: docker compose up --detach
|
||||
|
||||
- name: Install Elixir and JS deps
|
||||
run: |
|
||||
docker compose exec -T phx mix deps.get && yarn install && cd assets && yarn install && cd ..
|
||||
|
||||
- name: Create and Migrate database
|
||||
run: |
|
||||
docker compose exec -T phx mix ecto.create
|
||||
docker compose exec -T phx mix ecto.migrate
|
||||
|
||||
- name: Run code checks
|
||||
run: docker compose exec -T phx mix check --no-fix --no-retry
|
||||
|
||||
release-please:
|
||||
name: Release Please
|
||||
runs-on: ubuntu-latest
|
||||
needs: test
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
outputs:
|
||||
release_created: ${{ steps.release.outputs.release_created }}
|
||||
tag_name: ${{ steps.release.outputs.tag_name }}
|
||||
steps:
|
||||
- uses: googleapis/release-please-action@v4
|
||||
id: release
|
||||
with:
|
||||
config-file: release-please-config.json
|
||||
manifest-file: .release-please-manifest.json
|
||||
|
||||
# After a release is published: update mix.exs to CalVer so the running app
|
||||
# reports the date-based version while GitHub releases/tags stay semver.
|
||||
update-mix-version:
|
||||
name: Update mix.exs to CalVer
|
||||
runs-on: ubuntu-latest
|
||||
needs: release-please
|
||||
if: needs.release-please.outputs.release_created == 'true'
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Checkout master
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: master
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Bump mix.exs version to today's CalVer
|
||||
run: |
|
||||
DATE=$(date +"%Y.%-m.%-d")
|
||||
CURRENT=$(grep 'version: ' mix.exs | cut -d '"' -f2)
|
||||
sed -i "s/version: \"$CURRENT\"/version: \"$DATE\"/" mix.exs
|
||||
|
||||
- name: Commit and push
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add mix.exs
|
||||
git diff --cached --quiet || git commit -m "chore: update app version to $(date +"%Y.%-m.%-d") [skip ci]"
|
||||
git push
|
||||
|
||||
docker:
|
||||
name: Build and Push Docker Image
|
||||
runs-on: ubuntu-latest
|
||||
needs: [test, release-please]
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
env:
|
||||
dev_arch: 'linux/amd64'
|
||||
release_arch: 'linux/amd64,linux/arm64'
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Strip v prefix from release tag
|
||||
id: version
|
||||
if: needs.release-please.outputs.release_created == 'true'
|
||||
run: |
|
||||
echo "value=$(echo '${{ needs.release-please.outputs.tag_name }}' | sed 's/^v//')" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
docker.io/communitymaintained/pinchflat
|
||||
ghcr.io/${{ github.repository }}
|
||||
tags: |
|
||||
type=raw,value=${{ steps.version.outputs.value }},enable=${{ needs.release-please.outputs.release_created == 'true' }}
|
||||
type=raw,value=latest,enable=${{ needs.release-please.outputs.release_created == 'true' }}
|
||||
type=raw,value=dev,enable=${{ needs.release-please.outputs.release_created != 'true' }}
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and Push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: ./docker/selfhosted.Dockerfile
|
||||
platforms: ${{ needs.release-please.outputs.release_created == 'true' && env.release_arch || env.dev_arch }}
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
3
.release-please-manifest.json
Normal file
3
.release-please-manifest.json
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
".": "0.9.9"
|
||||
}
|
||||
7
release-please-config.json
Normal file
7
release-please-config.json
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
|
||||
"release-type": "simple",
|
||||
"packages": {
|
||||
".": {}
|
||||
}
|
||||
}
|
||||
1
version.txt
Normal file
1
version.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
0.9.9
|
||||
Loading…
Reference in a new issue