Skip to content

Commit

Permalink
Fix(release): Update docker release process
Browse files Browse the repository at this point in the history
  • Loading branch information
pusewicz committed Feb 18, 2022
1 parent a83cbc3 commit 665e11e
Showing 1 changed file with 41 additions and 15 deletions.
56 changes: 41 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ on:
jobs:
release-please:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write # Request GITHUB_TOKEN to have packages write permissions

steps:
- uses: google-github-actions/release-please-action@v3
id: release
Expand All @@ -16,24 +21,39 @@ jobs:
package-name: statique
bump-minor-pre-major: true
version-file: "lib/statique/version.rb"

- uses: actions/checkout@v2
if: ${{ steps.release.outputs.release_created }}

- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
if: ${{ steps.release.outputs.release_created }}
- name: publish gem

- name: Get Ruby version
id: ruby_version
run: echo "::set-output name=ruby-version::$(cat .ruby-version | tr -d '\n')"
if: ${{ steps.release.outputs.release_created }}

- name: Get Statique version
id: statique_version
run: echo "::set-output name=statique-version::$(ruby -Ilib/statique -r version -e 'print Statique::VERSION')"
if: ${{ steps.release.outputs.release_created }}

- name: Build gem
run: rake build

- name: Publish gem
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n:github: Bearer ${GITHUB_TOKEN}\n" > $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem build *.gemspec
gem push *.gem
gem push pkg/statique-${STATIQUE_VERSION}.gem
gem push --key github --host https://rubygems.pkg.github.com/${{ github.actor }} pkg/statique-${STATIQUE_VERSION}.gem
env:
# Make sure to update the secret name
# if yours isn't named RUBYGEMS_AUTH_TOKEN
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
GITHUB_TOKEN: "${{secrets.GITHUB_TOKEN}}"
STATIQUE_VERSION: "${{ steps.statique_version.outputs['statique-version'] }}"
if: ${{ steps.release.outputs.release_created }}

- name: Set up QEMU
Expand All @@ -44,15 +64,18 @@ jobs:
uses: docker/setup-buildx-action@v1
if: ${{ steps.release.outputs.release_created }}

- name: Get Ruby version
id: ruby_version
run: echo "::set-output name=ruby-version::$(cat .ruby-version | tr -d '\n')"
if: ${{ steps.release.outputs.release_created }}
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ github.actor }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Get Statique version
id: statique_version
run: echo "::set-output name=statique-version::$(ruby -Ilib/statique -r version -e 'print Statique::VERSION')"
if: ${{ steps.release.outputs.release_created }}
- name: Login to Github Packages
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Docker image
uses: docker/build-push-action@v2
Expand All @@ -65,4 +88,7 @@ jobs:
tags: |
pusewicz/statique:latest
pusewicz/statique:${{ steps.statique_version.outputs['statique-version'] }}
ghcr.io/pusewicz/statique:latest
ghcr.io/pusewicz/statique:${{ steps.statique_version.outputs['statique-version'] }}
push: ${{ github.ref == 'refs/heads/main' }}
if: ${{ steps.release.outputs.release_created }}

0 comments on commit 665e11e

Please sign in to comment.