Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add docker build action #549

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7d31a75
ci: add docker build action
vnghia Jan 2, 2024
e17c2a2
docker: ignore .git for better cache
vnghia Jan 2, 2024
87a0e85
ci: add missing permissions
vnghia Jan 2, 2024
12637b4
cargo: remove cargo dist
vnghia Jan 2, 2024
bd813fc
ci: cache to github action
vnghia Jan 2, 2024
969051b
ci: move docker-release to `docker.yml`
vnghia Jan 2, 2024
db4b54a
ci: update image release tags
vnghia Jan 2, 2024
24b2f82
cargo: merge profile dist to profile release
vnghia Jan 2, 2024
e7f7f76
Merge branch 'main' into docker-build-pr
IgnisDa Jan 2, 2024
1fe5be9
ci: move deploy to docker
vnghia Jan 3, 2024
eb4c31a
Merge branch 'main'
IgnisDa Jan 3, 2024
c466d39
ci: only run deploy if docker success
vnghia Jan 4, 2024
e591c35
Merge branch 'main' into docker-build-pr
IgnisDa Jan 15, 2024
79dd887
ci: push semver tags only when default branch
IgnisDa Jan 15, 2024
b4847d1
ci: release for semver only
IgnisDa Jan 15, 2024
2c92bc5
ci: add deploy for workflow
IgnisDa Jan 15, 2024
af771ab
ci: change workflow name
IgnisDa Jan 15, 2024
fac2f92
ci: change image name
IgnisDa Jan 15, 2024
dd85cf8
ci: deploy docs only on release
IgnisDa Jan 15, 2024
840aea6
Merge branch 'main'
IgnisDa Jan 21, 2024
a3ddedd
ci: remove changelog
IgnisDa Jan 21, 2024
e12d13f
docs: remove section about changelogs
IgnisDa Jan 21, 2024
b176cb0
ci: remove useless files
IgnisDa Jan 21, 2024
ecddef9
Merge branch 'main'
IgnisDa Jan 22, 2024
7bee441
ci: change order of services
IgnisDa Jan 22, 2024
e6cb3ec
docs: improve wording
IgnisDa Jan 22, 2024
64d5b41
docs: remove outdated section from dashboard
IgnisDa Jan 22, 2024
fec7880
ci: do not release pr tag if on default branch
IgnisDa Jan 22, 2024
c50989f
Merge branch 'main'
IgnisDa Jan 28, 2024
f103af0
Merge branch 'main' into docker-build-pr
IgnisDa Apr 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions .chglog/CHANGELOG.tpl.md

This file was deleted.

30 changes: 0 additions & 30 deletions .chglog/config.yml

This file was deleted.

1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules
.moon/cache
.moon/docker
**/.env
.git
191 changes: 59 additions & 132 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,113 +9,17 @@ env:

on:
push:
branches:
- main
tags:
- "*-?v[0-9]+*"
pull_request:
branches:
- main

jobs:
create-release:
docker-build:
runs-on: ubuntu-latest
outputs:
has-releases: ${{ steps.create-release.outputs.has-releases }}
is-prerelease: ${{ steps.create-release.outputs.is-prerelease }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- name: Install cargo-dist
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.2.0/cargo-dist-installer.sh | sh
- id: create-release
run: |
cargo dist plan --tag=${{ github.ref_name }} --output-format=json > dist-manifest.json
echo "dist plan ran successfully"
cat dist-manifest.json

# Create the Github Release™ based on what cargo-dist thinks it should be
ANNOUNCEMENT_TITLE=$(jq --raw-output ".announcement_title" dist-manifest.json)
IS_PRERELEASE=$(jq --raw-output ".announcement_is_prerelease" dist-manifest.json)
jq --raw-output ".announcement_github_body" dist-manifest.json > new_dist_announcement.md
gh release create ${{ github.ref_name }} --draft --prerelease="$IS_PRERELEASE" --title="$ANNOUNCEMENT_TITLE" --notes-file=new_dist_announcement.md
echo "created announcement!"
echo "is-prerelease=$IS_PRERELEASE" >> "$GITHUB_OUTPUT"

# Upload the manifest to the Github Release™
gh release upload ${{ github.ref_name }} dist-manifest.json
echo "uploaded manifest!"

# Disable all the upload-artifacts tasks if we have no actual releases
HAS_RELEASES=$(jq --raw-output ".releases != null" dist-manifest.json)
echo "has-releases=$HAS_RELEASES" >> "$GITHUB_OUTPUT"

upload-artifacts:
needs: create-release
if: ${{ needs.create-release.outputs.has-releases == 'true' }}
strategy:
matrix:
include:
- os: ubuntu-20.04
dist-args: --artifacts=global
install-dist: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.2.0/cargo-dist-installer.sh | sh
- os: macos-11
dist-args: --artifacts=local --target=aarch64-apple-darwin --target=x86_64-apple-darwin
install-dist: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.2.0/cargo-dist-installer.sh | sh
- os: ubuntu-20.04
dist-args: --artifacts=local --target=x86_64-unknown-linux-gnu
install-dist: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.2.0/cargo-dist-installer.sh | sh

runs-on: ${{ matrix.os }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install nodejs dependencies
run: yarn install --immutable
- name: Setup Moon
uses: moonrepo/setup-moon-action@v1.2.0
- name: Install cargo-dist
run: ${{ matrix.install-dist }}
- name: Build the frontend
run: moon run frontend:build
- name: Run cargo-dist
run: |
# Actually do builds and make zips and whatnot
cargo dist build --tag=${{ github.ref_name }} --output-format=json ${{ matrix.dist-args }} > dist-manifest.json
echo "dist ran successfully"
cat dist-manifest.json

# Parse out what we just built and upload it to the Github Release™
jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json > uploads.txt
echo "uploading..."
cat uploads.txt
gh release upload ${{ github.ref_name }} $(cat uploads.txt)
echo "uploaded!"

upload-kodi-plugin:
needs: create-release
runs-on: ubuntu-20.04
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install nodejs dependencies
run: yarn install --immutable
- name: Setup Moon
uses: moonrepo/setup-moon-action@v1.2.0
- name: Build plugin
run: |
moon run kodi:build
- name: Upload plugin to releases
run: |
gh release upload ${{ github.ref_name }} "tmp/script.ryot.zip"

docker-release:
runs-on: ubuntu-latest
needs: create-release
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -133,44 +37,33 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get docker image name and build args
id: required_args
run: |
image_name="${{ env.REGISTRY }}/${{ github.actor }}/${{ github.event.repository.name }}"
image_names="$image_name:${{ github.ref_name }},$image_name:unstable"
if [ "${{ needs.create-release.outputs.is-prerelease }}" = "false" ]; then
image_names="$image_names,$image_name:latest"
fi
# lowercase the name
image_names=$(echo "$image_names" | tr '[:upper:]' '[:lower:]')
echo "image_names=$image_names" >> $GITHUB_OUTPUT
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: |
name=${{ env.REGISTRY }}/${{ github.repository }}
tags: |
type=ref,event=pr,enable={{!is_default_branch}}
type=semver,pattern=v{{version}},enable={{is_default_branch}}
type=semver,pattern=v{{major}}.{{minor}},enable={{is_default_branch}}
type=semver,pattern=v{{major}},enable={{is_default_branch}}
type=raw,value=unstable,enable={{is_default_branch}}

- name: Build and push to ghcr
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.required_args.outputs.image_names }}

# Mark the Github Release™ as a non-draft now that everything has succeeded!
publish-release:
# Only run after all the other tasks, but it's ok if upload-artifacts was skipped
needs:
[create-release, upload-artifacts, docker-release, upload-kodi-plugin]
if: ${{ always() && needs.create-release.result == 'success' && (needs.upload-artifacts.result == 'skipped' || needs.upload-artifacts.result == 'success') }}
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- name: mark release as non-draft
run: |
gh release edit ${{ github.ref_name }} --draft=false
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max

deploy:
runs-on: ubuntu-latest
needs: docker-release
needs: docker-build
if: ${{ needs.docker-build.result == 'success' && github.ref == 'refs/heads/main' }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -183,21 +76,55 @@ jobs:
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

release:
runs-on: ubuntu-latest
needs: docker-build
if: ${{ needs.docker-build.result == 'success' && startsWith(github.ref, 'refs/tags/') }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Create a new release
uses: softprops/action-gh-release@v1

- name: Install nodejs dependencies
run: yarn install --immutable

- name: Setup Moon
uses: moonrepo/setup-moon-action@v1.2.0

- name: Build plugin
run: |
moon run kodi:build

- name: Upload plugin to releases
run: |
gh release upload ${{ github.ref_name }} "tmp/script.ryot.zip"

deploy-docs:
# otherwise the docs dislay the incorrect version
needs: publish-release
needs: release
runs-on: ubuntu-latest
if: ${{ needs.release.result == 'success' }}
defaults:
run:
working-directory: docs

steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: 3.x

- name: Install poetry
uses: abatilo/actions-poetry@v2

- name: Install dependencies
run: poetry install

- name: Deploy to github pages
run: poetry run mkdocs gh-deploy --force
Loading
Loading