diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 2426a84db..000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,191 +0,0 @@ -name: build -on: - workflow_run: - workflows: [ci] - types: [completed] - branches: [main, release] -concurrency: - group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch }} - cancel-in-progress: true -jobs: - info: - name: Collect information - runs-on: ubuntu-latest - if: github.event.workflow_run.conclusion != 'failure' && github.event.repository.full_name == 'reearth/reearth' && (github.event.workflow_run.head_branch == 'release' || !startsWith(github.event.head_commit.message, 'v')) - outputs: - sha_short: ${{ steps.info.outputs.sha_short }} - tag: ${{ steps.info.outputs.tag }} - tag_short: ${{ steps.info.outputs.tag_short }} - name: ${{ steps.info.outputs.name }} - steps: - - name: checkout - uses: actions/checkout@v3 - with: - ref: ${{ github.event.workflow_run.head_sha }} - - name: Fetch tags - run: git fetch --prune --unshallow --tags - - name: Get info - id: info - env: - BRANCH: ${{ github.event.workflow_run.head_branch }} - # The tag name should be retrieved lazily, as tagging may be delayed. - run: | - echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - if [[ "$BRANCH" = "release" ]]; then - TAG=$(git tag --points-at HEAD) - if [[ ! -z "$TAG" ]]; then - echo "::set-output name=tag::$TAG" - echo "::set-output name=tag_short::${TAG#v}" - else - echo "::set-output name=name::rc" - fi - else - echo "::set-output name=name::nightly" - fi - - name: Show info - env: - SHA_SHORT: ${{ steps.info.outputs.sha_short }} - TAG: ${{ steps.info.outputs.tag }} - TAG_SHORT: ${{ steps.info.outputs.tag_short }} - NAME: ${{ steps.info.outputs.name }} - run: echo "sha_short=$SHA_SHORT, tag=$TAG, tag_short=$TAG_SHORT, name=$NAME" - build: - name: Build and release - runs-on: ubuntu-latest - needs: - - info - if: needs.info.outputs.name || needs.info.outputs.tag - env: - ARTIFACTS: server/dist/reearth_*.* - ARTIFACTS_WEB: reearth-web_${{ needs.info.outputs.name || needs.info.outputs.tag }}.tar.gz - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - ref: ${{ github.event.workflow_run.head_sha }} - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: "1.19" - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v2 - with: - args: release --rm-dist ${{ env.SNAPSHOT }} - workdir: server - env: - SNAPSHOT: ${{ !needs.info.outputs.tag && '--snapshot' || '' }} - GORELEASER_CURRENT_TAG: ${{ needs.info.outputs.tag || '0.0.0' }} - - name: Fetch reearth-web release - uses: dsaltares/fetch-gh-release-asset@master - with: - repo: reearth/reearth-web - version: tags/${{ needs.info.outputs.name || needs.info.outputs.tag }} - file: ${{ env.ARTIFACTS_WEB }} - token: ${{ secrets.GITHUB_TOKEN }} - - name: Rename artifacts - if: needs.info.outputs.name - run: for f in $ARTIFACTS; do mv $f $(echo $f | sed -E 's/_0\.0\.0-SNAPSHOT-[^_]*/_${{ needs.info.outputs.name }}/'); done - - name: List artifacts - run: ls -l server/dist - - name: Release nightly/rc - if: needs.info.outputs.name - uses: ncipollo/release-action@v1 - with: - allowUpdates: true - artifacts: ${{ env.ARTIFACTS }},${{ env.ARTIFACTS_WEB }} - commit: ${{ github.sha }} - name: ${{ needs.info.outputs.name }} - tag: ${{ needs.info.outputs.name }} - body: ${{ needs.info.outputs.sha_short }} - prerelease: true - - name: Download latest changelog - if: needs.info.outputs.tag - uses: dawidd6/action-download-artifact@v2 - with: - workflow: release.yml - name: changelog-${{ needs.info.outputs.tag }} - - name: Create GitHub release - if: needs.info.outputs.tag - uses: ncipollo/release-action@v1 - with: - artifacts: ${{ env.ARTIFACTS }},${{ env.ARTIFACTS_WEB }} - commit: ${{ github.sha }} - name: ${{ needs.info.outputs.tag }} - tag: ${{ needs.info.outputs.tag }} - bodyFile: CHANGELOG_latest.md - docker: - name: Build and push Docker image - runs-on: ubuntu-latest - needs: - - info - if: needs.info.outputs.name || needs.info.outputs.tag - env: - IMAGE_NAME: reearth/reearth - defaults: - run: - working-directory: server - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - ref: ${{ github.event.workflow_run.head_sha }} - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Get options - id: options - env: - TAG: ${{ needs.info.outputs.tag_short }} - NAME: ${{ needs.info.outputs.name }} - SHA: ${{ needs.info.outputs.sha_short }} - run: | - if [[ -n $TAG ]]; then - PLATFORMS=linux/amd64,linux/arm64 - VERSION=$TAG - TAGS=$IMAGE_NAME:$TAG - if [[ ! $TAG =~ '-' ]]; then - TAGS+=,${IMAGE_NAME}:${TAG%.*} - TAGS+=,${IMAGE_NAME}:${TAG%%.*} - TAGS+=,${IMAGE_NAME}:latest - fi - else - PLATFORMS=linux/amd64 - VERSION=$SHA - TAGS=$IMAGE_NAME:$NAME - fi - echo "::set-output name=platforms::$PLATFORMS" - echo "::set-output name=version::$VERSION" - echo "::set-output name=tags::$TAGS" - - name: Fetch reearth-web release - uses: dsaltares/fetch-gh-release-asset@master - with: - repo: reearth/reearth-web - version: tags/${{ needs.info.outputs.name || needs.info.outputs.tag }} - file: reearth-web_${{ needs.info.outputs.name || needs.info.outputs.tag }}.tar.gz - token: ${{ secrets.GITHUB_TOKEN }} - target: server/reearth-web.tar.gz - - name: Extract reearth-web - run: tar -xvf reearth-web.tar.gz; mv reearth-web web; ls - - name: Build and push docker image - uses: docker/build-push-action@v3 - with: - context: server - platforms: ${{ steps.options.outputs.platforms }} - push: true - build-args: VERSION=${{ steps.options.outputs.version }} - tags: ${{ steps.options.outputs.tags }} - cache-from: type=gha - cache-to: type=gha,mode=max - - name: Invoke deploy_test workflow - uses: benc-uk/workflow-dispatch@v1 - if: needs.info.outputs.name == 'nightly' - with: - workflow: deploy_test - token: ${{ secrets.GPT }} \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 50c851dd9..000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: CI -on: - push: - branches: [main, release] - pull_request: -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true -jobs: - ci: - name: CI - runs-on: ubuntu-latest - if: github.event_name != 'push' || !startsWith(github.event.head_commit.message, 'v') - services: - mongo: - image: mongo:5-focal - ports: - - 27017:27017 - steps: - - name: set up - uses: actions/setup-go@v3 - with: - go-version: "1.19" - - name: checkout - uses: actions/checkout@v3 - - name: cache - uses: actions/cache@v3 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - name: golangci-lint - uses: golangci/golangci-lint-action@v3 - with: - version: v1.52 - args: --timeout=10m - working-directory: server - - name: test - run: go test ./... -v -race -coverprofile=coverage.txt -covermode=atomic -timeout 10m - env: - REEARTH_DB: mongodb://localhost - working-directory: server - - name: Send coverage report - uses: codecov/codecov-action@v2 - with: - token: ${{ secrets.CODECOV_TOKEN }} - file: coverage.txt \ No newline at end of file diff --git a/.github/workflows/deploy_test.yml b/.github/workflows/deploy_test.yml deleted file mode 100644 index e0fa88a22..000000000 --- a/.github/workflows/deploy_test.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: deploy_test -on: - workflow_dispatch: -concurrency: - group: ${{ github.workflow }} - cancel-in-progress: true -env: - IMAGE: reearth/reearth:nightly - IMAGE_GCP: us.gcr.io/reearth-oss/reearth:nightly - GCP_REGION: us-central1 -jobs: - deploy_test: - name: Deploy app to test env - runs-on: ubuntu-latest - if: github.event.repository.full_name == 'reearth/reearth' - steps: - - uses: google-github-actions/auth@v0 - with: - credentials_json: ${{ secrets.GCP_SA_KEY }} - - name: Set up Cloud SDK - uses: google-github-actions/setup-gcloud@v0 - - name: Configure docker - run: gcloud auth configure-docker --quiet - - name: docker push - run: | - docker pull $IMAGE - docker tag $IMAGE $IMAGE_GCP - docker push $IMAGE_GCP - - name: Deploy to Cloud Run - run: | - gcloud run deploy reearth-backend \ - --image $IMAGE_GCP \ - --region $GCP_REGION \ - --platform managed \ - --quiet \ No newline at end of file