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

feat!: Drop WASM target, add Docker #50

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
target/
.envrc
.github/
docs/
48 changes: 28 additions & 20 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,51 @@
name: Deploy

on:
push:
branches:
- main
workflow_call:
inputs:
version:
description: 'Version to deploy'
type: string

# Prevent parallel deployments
concurrency:
group: ${{ github.workflow }}-pyoci.allexveldman.nl
group: ${{ github.workflow }}-pyoci.com
cancel-in-progress: false


jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
timeout-minutes: 10

permissions:
id-token: write

environment:
name: pyoci
url: https://pyoci.allexveldman.nl
name: pyoci.com
url: https://pyoci.com

steps:
- uses: extractions/setup-just@v2
- uses: actions/checkout@v4
- uses: actions/cache@v4
- name: Azure login
uses: azure/login@v2
with:
path: |
~/.cargo
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: Deploy
uses: cloudflare/wrangler-action@v3
- name: Azure CLI script
uses: azure/cli@v2
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
azcliversion: latest
inlineScript: >
az containerapp revision copy
--name pyoci
--resource-group PyOCI
--image ghcr.io/allexveldman/pyoci:${{ inputs.version }}
--tags version=${{ inputs.version }} sha=${{ github.sha }}
--revision-suffix=${{ inputs.version }}-${{ github.run_number }}-${{ github.run_attempt }}


examples:
name: Examples
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Version
id: version
run: |
echo "VERSION=0.0.1+example-poetry-$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
echo "VERSION=0.0.1+example-${{ github.run_attempt }}-poetry-$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"

- name: Publish
run: |
Expand Down
78 changes: 78 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Publish

on:
push:
tags:
- '*'
branches:
- main
pull_request:

concurrency:
# Cancel existing runs when pushing to the same branch of a PR
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions:
contents: read
packages: write

jobs:
build:
runs-on: ubuntu-latest
name: Build
timeout-minutes: 15

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

steps:
- uses: actions/checkout@v4
- uses: docker/metadata-action@v5
name: Docker meta
id: meta
with:
images: |
ghcr.io/allexveldman/pyoci
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GHCR
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/Dockerfile
cache-from: type=registry,ref=ghcr.io/allexveldman/pyoci:latest
cache-to: type=inline
push: ${{ github.ref_type == 'tag' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

deploy:
name: Deploy
needs: [build]
if: ${{ github.ref_type == 'tag' }}
uses: ./.github/workflows/deploy.yaml
with:
version: ${{ needs.build.outputs.version }}
secrets: inherit
permissions:
contents: read
id-token: write
packages: write
6 changes: 0 additions & 6 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ jobs:
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: Build
run: just build

- name: Test
run: just test-coverage

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ build/
node_modules/
.venv/
lcov.info
.envrc
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ repos:
pass_filenames: false
language: system
entry: |
cargo clippy --target wasm32-unknown-unknown -- -D warnings
cargo clippy -- -D warnings
Loading
Loading