forked from assembler/attachinary
-
Notifications
You must be signed in to change notification settings - Fork 3
42 lines (40 loc) · 1.69 KB
/
test.yaml
File metadata and controls
42 lines (40 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
name: Run Tests and Publish
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1.3
- name: Build and test with Rake
run: |
gem install bundler
bundle install --jobs 4 --retry 3
cp spec/dummy/config/cloudinary.yml.example spec/dummy/config/cloudinary.yml
sed -i s/CLOUD_NAME/${{ secrets.CLOUDINARY_DEV_CLOUD_NAME }}/g spec/dummy/config/cloudinary.yml
sed -i s/API_KEY/${{ secrets.CLOUDINARY_DEV_API_KEY }}/g spec/dummy/config/cloudinary.yml
sed -i s/API_SECRET/${{ secrets.CLOUDINARY_DEV_API_SECRET }}/g spec/dummy/config/cloudinary.yml
bundle exec rake spec
gem build attachinary.gemspec
- name: Publish gem
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
bundle config rubygems.pkg.github.com reverb-deploy-bot:${{ secrets.GITHUB_TOKEN }}
bundle config set frozen true
bundle install
CURRENT_VERSION=$(bundle info attachinary --version)
set +e
mkdir -p ~/.gem
echo -e "---\n:github: Bearer ${{ secrets.PACKAGE_PULL_TOKEN }}" >> ~/.gem/credentials
VERSION_MATCH=$(gem search attachinary -s https://${{ secrets.GITHUB_TOKEN }}@rubygems.pkg.github.com/reverbdotcom | grep -c $CURRENT_VERSION)
set -e
if [ $VERSION_MATCH -ne 0 ]; then
echo "Version already exists! No need to publish"
exit 0
fi
gem build attachinary.gemspec
chmod 0600 ~/.gem/credentials
gem push --key github --host https://rubygems.pkg.github.com/reverbdotcom attachinary*.gem