From cb75c44ff882d20c23fb32effc7e7bf4bd27abc5 Mon Sep 17 00:00:00 2001 From: Florian Dejonckheere Date: Mon, 4 Dec 2023 18:17:25 +0100 Subject: [PATCH] Add build and release workflows --- .github/workflows/ci.yml | 60 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b1580c..c49a290 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,8 +26,68 @@ jobs: - name: Lint run: yarn lint + - name: Typecheck + run: yarn tsc + - name: Test run: yarn test - name: Build run: yarn build + + build: + name: Build application + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-22.04 + + needs: + - app + + steps: + - name: Set version + run: | + echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + with: + driver-opts: image=moby/buildkit:master + + - name: Login to Github Packages + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.DOCKER_TOKEN }} + + - name: Build and push app to GitHub Packages + uses: docker/build-push-action@v2.0.1 + with: + file: Dockerfile + push: true + tags: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ env.VERSION }} + + release: + name: Create release + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-22.04 + needs: build + + steps: + - name: Set version + run: | + echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV + + - name: Create Github Release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.event.repository.name }} ${{ env.VERSION }} + prerelease: contains(github.ref, '-') + body: | + Application ${{ github.event.repository.name }} ${{ env.VERSION }} was released