diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..2d33829 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,16 @@ +changelog: + exclude: + labels: + - ignore-for-release + categories: + - title: Breaking Changes 🛠 + labels: + - Semver-Major + - breaking-change + - title: Exciting New Features 🎉 + labels: + - Semver-Minor + - enhancement + - title: Other Changes + labels: + - "*" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..08c0c06 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,37 @@ +name: Build latest image +on: + push: + branches: + - main + paths-ignore: + - '*.md' + - 'LICENSE' + +jobs: + publish: + runs-on: self-hosted + steps: + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: | + ghcr.io/defguard/defguard-proxy + tags: | + type=raw,value=latest + type=ref,event=branch + type=sha + - name: Login to GitHub container registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Build container + uses: docker/build-push-action@v3 + with: + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/lint-web.yml b/.github/workflows/lint-web.yml new file mode 100644 index 0000000..6b10bd3 --- /dev/null +++ b/.github/workflows/lint-web.yml @@ -0,0 +1,30 @@ +name: Lint frontend + +on: + push: + branches: + - main + paths: + - "web/**" + pull_request: + branches: + - main + paths: + - "web/**" + +jobs: + lint-web: + runs-on: self-hosted + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 19 + - name: install deps + working-directory: ./web + run: | + npm i -g pnpm + pnpm i --frozen-lockfile + - name: Lint + working-directory: ./web + run: pnpm lint diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..88f5fb6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,52 @@ +name: Make a new release + +on: + push: + tags: + - v*.*.* + +jobs: + publish-docker: + runs-on: self-hosted + steps: + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: | + ghcr.io/DefGuard/defguard-proxy + tags: | + type=ref,event=branch + type=ref,event=pr + type=raw,value=latest,enable=${{ github.event_name != 'pull_request' }} + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to GitHub container registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build container + uses: docker/build-push-action@v3 + with: + # platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + release: + runs-on: self-hosted + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Create release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + generate_release_notes: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..cb3746f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,49 @@ +name: Test backend + +on: + push: + branches: + - main + paths-ignore: + - '*.md' + - 'LICENSE' + pull_request: + branches: + - main + paths-ignore: + - '*.md' + - 'LICENSE' + +env: + CARGO_TERM_COLOR: always + +jobs: + test: + runs-on: self-hosted + container: rust:1.71 + + steps: + - name: Debug + run: echo ${{ github.ref_name }} + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: recursive + - name: Cache + uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Install protoc + run: apt-get update && apt-get -y install protobuf-compiler + - name: Check format + run: | + rustup component add rustfmt + cargo fmt -- --check + - name: Run tests + run: cargo test --locked --no-fail-fast