name: Default on: push: jobs: build: name: Build runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Set up Ruby 2.6 uses: actions/setup-ruby@v1 with: ruby-version: 2.6.x - uses: actions/cache@v1 with: path: vendor/bundle key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} restore-keys: ${{ runner.os }}-gems- - name: Install Bundler run: gem install bundler - name: Configure Bundler run: bundle config path vendor/bundle - name: Bundle Install run: bundle install --jobs 4 --retry 3 - name: Set EUFYCAM_VERSION run: echo ::set-env name=EUFYCAM_VERSION::$(bundle exec rake version:current) - name: Build run: bundle exec rake build - name: Upload Gem uses: actions/upload-artifact@v1 with: name: eufycam-${{ env.EUFYCAM_VERSION }}.gem path: eufycam-${{ env.EUFYCAM_VERSION }}.gem lint: name: Lint runs-on: ubuntu-latest needs: [build] steps: - uses: actions/checkout@v2 - name: Set up Ruby 2.6 uses: actions/setup-ruby@v1 with: ruby-version: 2.6.x - uses: actions/cache@v1 with: path: vendor/bundle key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} restore-keys: ${{ runner.os }}-gems- - name: Install Bundler run: gem install bundler - name: Configure Bundler run: bundle config path vendor/bundle - name: Bundle Install run: bundle install --jobs 4 --retry 3 - name: Run Rubocop run: bundle exec rubocop test: name: Test runs-on: ubuntu-latest needs: [build] steps: - uses: actions/checkout@v2 - name: Set up Ruby 2.6 uses: actions/setup-ruby@v1 with: ruby-version: 2.6.x - uses: actions/cache@v1 with: path: vendor/bundle key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} restore-keys: ${{ runner.os }}-gems- - name: Install Bundler run: gem install bundler - name: Configure Bundler run: bundle config path vendor/bundle - name: Bundle Install run: bundle install --jobs 4 --retry 3 - name: Run RSpec run: bundle exec rake spec release: name: Release runs-on: ubuntu-latest if: ${{ startsWith(github.ref, 'refs/tags/v') }} needs: [test, lint] steps: - uses: actions/checkout@v2 - name: Set up Ruby 2.6 uses: actions/setup-ruby@v1 with: ruby-version: 2.6.x - uses: actions/cache@v1 with: path: vendor/bundle key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} restore-keys: ${{ runner.os }}-gems- - name: Install Bundler run: gem install bundler - name: Configure Bundler run: bundle config path vendor/bundle - name: Configure Gem run: | mkdir -p $HOME/.gem touch $HOME/.gem/credentials chmod 0600 $HOME/.gem/credentials printf -- "---\n:rubygems_api_key: ${{secrets.RUBYGEMS_API_KEY}}\n:github: Bearer ${{secrets.PERSONAL_ACCESS_TOKEN}}" > $HOME/.gem/credentials - name: Bundle Install run: bundle install --jobs 4 --retry 3 - name: Set EUFYCAM_VERSION run: echo ::set-env name=EUFYCAM_VERSION::$(bundle exec rake version:current) - uses: actions/download-artifact@v1 with: name: eufycam-${{ env.EUFYCAM_VERSION }}.gem path: /tmp - run: mv /tmp/eufycam-${{ env.EUFYCAM_VERSION }}.gem . - name: Push Gem to Rubygems run: bundle exec rake release[rubygems] continue-on-error: true - name: Push Gem to Github Package Registry run: bundle exec rake release[github] continue-on-error: true - name: Create Release id: create_release uses: actions/create-release@latest env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ github.ref }} release_name: ${{ github.ref }} draft: false prerelease: false - uses: docker/build-push-action@v1 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} repository: kyledecot/eufycam tags: "latest, ${{ env.EUFYCAM_VERSION }}" - uses: docker/build-push-action@v1 with: username: ${{ github.actor }} password: ${{secrets.PERSONAL_ACCESS_TOKEN}} repository: kyledecot/eufycam/eufycam registry: docker.pkg.github.com tags: "latest, ${{ env.EUFYCAM_VERSION }}" - name: Upload Release Asset uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_path: eufycam-${{ env.EUFYCAM_VERSION }}.gem asset_name: eufycam-${{ env.EUFYCAM_VERSION }}.gem asset_content_type: application/binary