name: Publish Release

on:
  release:
    types: [created]

jobs:
  build:
    uses: ./.github/workflows/build.yml

  publish-npm:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: ./.github/actions/setup
      - run: yarnpkg publish --non-interactive
        env:
          NPM_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

  publish-site:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: ./.github/actions/setup
      - run: sudo apt-get install awscli
      - run: yarnpkg build
      - name: aws s3 sync
        run: |
          aws configure set region eu-central-1
          aws configure set aws_access_key_id ${{secrets.AWS_ACCESS_KEY_ID}}
          aws configure set aws_secret_access_key ${{secrets.AWS_SECRET_ACCESS_KEY}}
          aws s3 sync public/waforth/ s3://${{secrets.AWS_SITE_BUCKET}}/waforth/