Skip to content

Commit

Permalink
Refactor release-prep and action due to issue running via docker
Browse files Browse the repository at this point in the history
  • Loading branch information
yachub committed Aug 16, 2023
1 parent d6e6d67 commit b4fd3d7
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 38 deletions.
94 changes: 61 additions & 33 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
name: Release Gem

on: workflow_dispatch
on: push

jobs:
release:
validate-release:
runs-on: ubuntu-latest
if: github.repository == 'puppetlabs/vmpooler'
outputs:
cv: ${{ steps.cv.outputs.version }}
nv: ${{ steps.nv.outputs.version }}
steps:
- uses: actions/checkout@v3

- name: Install Ruby 3.2
uses: ruby/setup-ruby@v1
with:
ruby-version: 'ruby-3.2'

- name: Get Current Version
uses: actions/github-script@v6
id: cv
Expand All @@ -30,10 +38,9 @@ jobs:
echo "Found version $version from lib/vmpooler/version.rb"
- name: Generate Changelog
uses: docker://githubchangeloggenerator/github-changelog-generator:1.16.2
with:
args: >-
--future-release ${{ steps.nv.outputs.version }}
run : |
gem install github_changelog_generator -v '~> 1.16'
github_changelog_generator --future-release ${{ steps.nv.outputs.version }}
env:
CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -51,39 +58,60 @@ jobs:
fi
- name: Generate Release Notes
uses: docker://githubchangeloggenerator/github-changelog-generator:1.16.2
with:
args: >-
--since-tag ${{ steps.cv.outputs.result }}
--future-release ${{ steps.nv.outputs.version }}
run : |
github_changelog_generator \
--since-tag ${{ steps.cv.outputs.result }} \
--future-release ${{ steps.nv.outputs.version }} \
--output release-notes.md
env:
CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Tag Release
uses: ncipollo/release-action@v1
- uses: actions/upload-artifact@v3
with:
tag: ${{ steps.nv.outputs.version }}
token: ${{ secrets.GITHUB_TOKEN }}
bodyfile: release-notes.md
draft: false
prerelease: false
name: release-notes
path: release-notes.md

# This step should closely match what is used in `docker/Dockerfile` in vmpooler-deployment
- name: Install Ruby jruby-9.4.3.0
uses: ruby/setup-ruby@v1
publish-release:
runs-on: ubuntu-latest
needs: validate-release
if: github.repository == 'puppetlabs/vmpooler'
steps:
- uses: actions/checkout@v3

- uses: actions/download-artifact@v3
with:
ruby-version: 'jruby-9.4.3.0'
name: release-notes
path: release-notes.md

- name: Test Outputs
run : |
cat release-notes.md
echo ${{ needs.validate-release.outputs.nv.version }}
- name: Build gem
run: gem build *.gemspec
# - name: Tag Release
# uses: ncipollo/release-action@v1
# with:
# tag: ${{ needs.validate-release.outputs.nv.version }}
# token: ${{ secrets.GITHUB_TOKEN }}
# bodyfile: release-notes.md
# draft: false
# prerelease: false

- name: Publish gem
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem push *.gem
env:
GEM_HOST_API_KEY: '${{ secrets.RUBYGEMS_AUTH_TOKEN }}'
# # This step should closely match what is used in `docker/Dockerfile` in vmpooler-deployment
# - name: Install Ruby jruby-9.4.3.0
# uses: ruby/setup-ruby@v1
# with:
# ruby-version: 'jruby-9.4.3.0'

# - name: Build gem
# run: gem build *.gemspec

# - name: Publish gem
# run: |
# mkdir -p $HOME/.gem
# touch $HOME/.gem/credentials
# chmod 0600 $HOME/.gem/credentials
# printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
# gem push *.gem
# env:
# GEM_HOST_API_KEY: '${{ secrets.RUBYGEMS_AUTH_TOKEN }}'
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## [3.3.0](https://github.com/puppetlabs/vmpooler/tree/3.3.0) (2023-08-15)
## [3.3.0](https://github.com/puppetlabs/vmpooler/tree/3.3.0) (2023-08-16)

[Full Changelog](https://github.com/puppetlabs/vmpooler/compare/3.2.0...3.3.0)

Expand Down
6 changes: 2 additions & 4 deletions release-prep
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,5 @@ docker run -it --rm \
/bin/bash -c 'apt-get update -qq && apt-get install -y --no-install-recommends git make netbase && cd /app && gem install bundler && bundle install --jobs 3; echo "LOCK_FILE_UPDATE_EXIT_CODE=$?"'

# Update Changelog
docker run -it --rm -e CHANGELOG_GITHUB_TOKEN -v $(pwd):/usr/local/src/your-app \
githubchangeloggenerator/github-changelog-generator:1.16.2 \
github_changelog_generator --future-release $(grep VERSION lib/vmpooler/version.rb |rev |cut -d "'" -f2 |rev)

gem install github_changelog_generator -v '~> 1.16'
github_changelog_generator --future-release $(grep VERSION lib/vmpooler/version.rb |rev |cut -d "'" -f2 |rev)

0 comments on commit b4fd3d7

Please sign in to comment.