This repository has been archived by the owner on May 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
125 additions
and
46 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,22 @@ | ||
name: notify-release | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
notify-discord: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Notify Discord | ||
uses: fjogeleit/http-request-action@v1 | ||
with: | ||
url: ${{ secrets.OKP4_DISCORD_WEBHOOK }} | ||
method: 'POST' | ||
customHeaders: '{"Content-Type": "application/json"}' | ||
data: |- | ||
{ | ||
"avatar_url": "https://avatars.githubusercontent.com/u/98603954?v=4", | ||
"username": "Bot Anik", | ||
"content": "🚨 A new version of @${{github.repository}} ${{ github.event.release.tag_name }} has been released! 🎉\n\n👉 Changelog: https://github.com/${{ github.repository }}/releases/tag/${{ github.event.release.tag_name }}\n👉 Official repo: https://github.com/${{ github.repository }}" | ||
} |
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 |
---|---|---|
|
@@ -4,30 +4,35 @@ on: | |
issue_comment: | ||
types: [created, edited] | ||
|
||
concurrency: | ||
group: publish-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
publish-docker-image: | ||
if: ${{ github.event.issue.pull_request && github.event.comment.body == '/publish' }} | ||
publish-docker-images: | ||
if: ${{ github.event.issue.pull_request && github.event.comment.body == '/publish' }} | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Set up context | ||
id: project_context | ||
uses: FranzDiebold/[email protected] | ||
- uses: xt0rted/pull-request-comment-branch@v1 | ||
id: comment-branch | ||
|
||
- name: Check out repository | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ steps.comment-branch.outputs.head_ref }} | ||
|
||
- uses: gacts/github-slug@v1 | ||
id: slug | ||
with: | ||
to-slug: ${{ steps.comment-branch.outputs.head_ref }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: docker_metadata | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ghcr.io/${{ github.repository }} | ||
tags: | | ||
type=raw,enable=${{ !endsWith(github.ref, github.event.repository.default_branch) }},value=${{ env.CI_ACTION_REF_NAME_SLUG }} | ||
type=raw,value=${{ steps.slug.outputs.slug }} | ||
labels: | | ||
org.opencontainers.image.vendor=OKP4 | ||
- name: Login to Docker registry | ||
- name: Login to GHCR | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
|
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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
name: Publish | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
tags: ["v*"] | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: publish-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
publish-docker-images: | ||
|
@@ -13,8 +15,82 @@ jobs: | |
- name: Check out repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install environment | ||
uses: actions/setup-python@v4 | ||
- name: Set up context | ||
id: project_context | ||
uses: FranzDiebold/[email protected] | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: docker_metadata | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ghcr.io/${{ github.repository }},${{ github.repository }} | ||
tags: | | ||
type=raw,value=nightly | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}} | ||
labels: | | ||
org.opencontainers.image.vendor=OKP4 | ||
- name: Login to GHCR | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ secrets.DOCKER_REGISTRY_ID }} | ||
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_REGISTRY_ID }} | ||
password: ${{ secrets.DOCKER_HUB_REGISTRY_TOKEN }} | ||
|
||
- name: Build and publish image(s) | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
platforms: linux/amd64 | ||
push: true | ||
tags: ${{ steps.docker_metadata.outputs.tags }} | ||
labels: ${{ steps.docker_metadata.outputs.labels }} | ||
|
||
dockerhub-description: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 2 | ||
|
||
- name: Find change in readme file | ||
id: readme-change | ||
uses: tj-actions/changed-files@v34 | ||
with: | ||
files: | | ||
README.md | ||
- name: Docker Hub Description | ||
if: steps.readme-change.outputs.any_changed == 'true' | ||
uses: peter-evans/dockerhub-description@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_REGISTRY_ID }} | ||
short-description: Docker image for https://github.com/${{ github.repository }} | ||
password: ${{ secrets.DOCKER_HUB_REGISTRY_TOKEN }} | ||
repository: ${{ github.repository }} | ||
readme-filepath: README.md | ||
|
||
publish-pypi: | ||
if: contains(github.ref, 'refs/tags/') | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up context | ||
id: project_context | ||
uses: FranzDiebold/[email protected] | ||
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.9 | ||
|
||
|
@@ -23,34 +99,10 @@ jobs: | |
with: | ||
poetry-version: 1.3.1 | ||
|
||
- name: Login to Docker registry | ||
run: | | ||
echo ${{ secrets.DOCKER_REGISTRY_TOKEN }} | docker login ghcr.io -u ${{ secrets.DOCKER_REGISTRY_ID }} --password-stdin | ||
- name: Set up target version | ||
id: project_context | ||
run: | | ||
version=`poetry version -s --no-ansi -n` | ||
echo "version=${version}" >> $GITHUB_OUTPUT | ||
echo "major=$(echo $version | cut -d. -f1)" >> $GITHUB_OUTPUT | ||
echo "minor=$(echo $version | cut -d. -f2)" >> $GITHUB_OUTPUT | ||
echo "revision=$(echo $version | cut -d. -f3)" >> $GITHUB_OUTPUT | ||
echo "image=${GITHUB_REPOSITORY}" >> $GITHUB_OUTPUT | ||
- name: Build and publish image(s) | ||
- name: Publish package | ||
working-directory: ${{env.WORK_DIR}} | ||
run: | | ||
if [[ $GITHUB_REF == refs/tags/v* ]]; then | ||
echo "Publish docker image for branch" | ||
docker build \ | ||
-t ghcr.io/${{ steps.project_context.outputs.image }}:${{ steps.project_context.outputs.major }} \ | ||
-t ghcr.io/${{ steps.project_context.outputs.image }}:${{ steps.project_context.outputs.major }}.${{ steps.project_context.outputs.minor }} \ | ||
-t ghcr.io/${{ steps.project_context.outputs.image }}:${{ steps.project_context.outputs.version }} \ | ||
-t ghcr.io/${{ steps.project_context.outputs.image }}:latest \ | ||
. | ||
else | ||
echo "Publish docker image for nightly" | ||
docker build \ | ||
-t ghcr.io/${{ steps.project_context.outputs.image }}:nightly \ | ||
. | ||
fi | ||
docker push ghcr.io/${{ steps.project_context.outputs.image }} --all-tags | ||
poetry install | ||
poetry build | ||
echo "🚀 Publishing pypi package" | ||
poetry publish -u __token__ -p "${{ secrets.PYPI_API_TOKEN }}" |
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