Skip to content

Commit

Permalink
Merge pull request #586 from github/no_more_ruby_packer
Browse files Browse the repository at this point in the history
Remove ruby packer usage and executable releases
  • Loading branch information
jonabc authored Dec 22, 2022
2 parents bdfad9f + a584a13 commit 79e4cc5
Show file tree
Hide file tree
Showing 22 changed files with 35 additions and 644 deletions.
4 changes: 0 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ updates:
directory: /
schedule:
interval: weekly
- package-ecosystem: docker
directory: docker
schedule:
interval: weekly
78 changes: 0 additions & 78 deletions .github/workflows/build-packer.yml

This file was deleted.

216 changes: 22 additions & 194 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,211 +3,39 @@ name: Build and publish release assets
on:
release:
types: [created]
workflow_dispatch:
inputs:
version:
description: 'Commit-like version of github/licensed to build package at'
required: true
release_tag:
description: 'Release tag to upload built packages to'
required: false

jobs:
vars:
name: "Gather values for remainder of steps"
build:
name: Build + Publish
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.result }}
upload_url: ${{ steps.get_url.outputs.result }}
ref: ${{ steps.get_ref.outputs.result }}
steps:
- id: get_version
name: Get package version
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
let version = "${{ github.event.release.tag_name }}"
if (!version) {
version = "${{ github.event.inputs.version }}"
}
if (!version) {
throw new Error("unable to find package build version")
}
return version
- id: get_url
name: Get release upload url
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
let uploadUrl = "${{ github.event.release.upload_url}}"
const tag = "${{ github.event.inputs.release_tag }}"
if (!uploadUrl && tag) {
const { data: release } = await github.rest.repos.getReleaseByTag({
...context.repo,
tag
})
if (!release.upload_url) {
throw new Error("unable to find a release upload url")
}
uploadUrl = release.upload_url
}
permissions:
contents: read
packages: write

return uploadUrl
- id: get_ref
name: Get checkout ref for custom build scripts
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
let ref = "${{ github.event.release.tag_name }}"
if (!ref) {
ref = "${{ github.event.ref }}".replace(/refs\/[^\/]+\//, '')
}
if (!ref) {
throw new Error("unable to find a ref for action")
}
return ref
package_linux:
needs: vars
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v3
with:
# checkout at the ref for the action, separate from the target build version
# this allows running build scripts independent of the target version
ref: ${{needs.vars.outputs.ref}}
fetch-depth: 0

- name: Set up Ruby 2.6
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

- name: Build package
run: script/packages/linux
env:
VERSION: ${{needs.vars.outputs.version}}

- uses: actions/upload-artifact@v3
with:
name: ${{needs.vars.outputs.version}}-linux
path: pkg/${{needs.vars.outputs.version}}/licensed-${{needs.vars.outputs.version}}-linux-x64.tar.gz

package_mac:
needs: vars
runs-on: macOS-latest
steps:
- uses: actions/checkout@v3
with:
# checkout at the ref for the action, separate from the target build version
# this allows running build scripts independent of the target version
ref: ${{needs.vars.outputs.ref}}
fetch-depth: 0

- name: Set up Ruby 2.6
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

- name: Build package
run: script/packages/mac
env:
VERSION: ${{needs.vars.outputs.version}}

- uses: actions/upload-artifact@v3
with:
name: ${{needs.vars.outputs.version}}-darwin
path: pkg/${{needs.vars.outputs.version}}/licensed-${{needs.vars.outputs.version}}-darwin-x64.tar.gz
- name: Set up Ruby
uses: actions/setup-ruby@v1

build_gem:
needs: vars
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# building a gem doesn't use a different ref from the version input
ref: ${{needs.vars.outputs.version}}

- name: Set up Ruby 2.6
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

- name: Build gem
run: gem build licensed.gemspec -o licensed-${{needs.vars.outputs.version}}.gem

- uses: actions/upload-artifact@v3
with:
name: ${{needs.vars.outputs.version}}-gem
path: licensed-${{needs.vars.outputs.version}}.gem

upload_packages:
if: ${{ needs.vars.outputs.upload_url != '' }}
runs-on: ubuntu-latest
needs: [vars, package_linux, package_mac, build_gem]

steps:
- name: Set up Ruby 2.6
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

- name: Download linux package
uses: actions/download-artifact@v3
with:
name: ${{needs.vars.outputs.version}}-linux

- name: Download macOS package
uses: actions/download-artifact@v3
with:
name: ${{needs.vars.outputs.version}}-darwin

- name: Download gem
uses: actions/download-artifact@v3
with:
name: ${{needs.vars.outputs.version}}-gem

- name: Publish linux package
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.vars.outputs.upload_url }}
asset_path: ./licensed-${{needs.vars.outputs.version}}-linux-x64.tar.gz
asset_name: licensed-${{needs.vars.outputs.version}}-linux-x64.tar.gz
asset_content_type: application/gzip

- name: Publish mac package
uses: actions/upload-release-asset@v1
- name: Publish to GPR
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem build *.gemspec
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.vars.outputs.upload_url }}
asset_path: ./licensed-${{needs.vars.outputs.version}}-darwin-x64.tar.gz
asset_name: licensed-${{needs.vars.outputs.version}}-darwin-x64.tar.gz
asset_content_type: application/gzip
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
OWNER: ${{ github.repository_owner }}

- name: Publish gem to RubyGems
- name: Publish to RubyGems
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${RUBYGEMS_API_KEY}\n" > $HOME/.gem/credentials
gem push $GEM
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem build *.gemspec
gem push *.gem
env:
RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
GEM: licensed-${{needs.vars.outputs.version}}.gem
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
2 changes: 1 addition & 1 deletion .licenses/bundler/json.dep.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: json
version: 2.6.2
version: 2.6.3
type: bundler
summary: JSON Implementation for Ruby
homepage: http://flori.github.com/json
Expand Down
2 changes: 1 addition & 1 deletion .licenses/bundler/licensee.dep.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: licensee
version: 9.15.2
version: 9.15.3
type: bundler
summary: A Ruby Gem to detect open source project licenses
homepage: https://github.com/benbalter/licensee
Expand Down
2 changes: 1 addition & 1 deletion .licenses/bundler/nokogiri.dep.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: nokogiri
version: 1.13.9
version: 1.13.10
type: bundler
summary: Nokogiri (鋸) makes it easy and painless to work with XML and HTML from Ruby.
homepage: https://nokogiri.org
Expand Down
2 changes: 1 addition & 1 deletion .licenses/bundler/octokit.dep.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: octokit
version: 4.25.1
version: 6.0.1
type: bundler
summary: Ruby toolkit for working with the GitHub API
homepage: https://github.com/octokit/octokit.rb
Expand Down
2 changes: 1 addition & 1 deletion .licenses/bundler/public_suffix.dep.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: public_suffix
version: 5.0.0
version: 5.0.1
type: bundler
summary: Domain name parser based on the Public Suffix List.
homepage: https://simonecarletti.com/code/publicsuffix-ruby
Expand Down
4 changes: 2 additions & 2 deletions .licenses/bundler/racc.dep.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
name: racc
version: 1.6.0
version: 1.6.1
type: bundler
summary: Racc is a LALR(1) parser generator
homepage: https://i.loveruby.net/en/projects/racc/
homepage: https://github.com/ruby/racc
license: other
licenses:
- sources: COPYING
Expand Down
2 changes: 1 addition & 1 deletion .licenses/bundler/reverse_markdown.dep.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: reverse_markdown
version: 1.4.0
version: 2.1.1
type: bundler
summary: Convert html code into markdown.
homepage: http://github.com/xijo/reverse_markdown
Expand Down
2 changes: 0 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ The following steps will happen automatically from a GitHub Actions workflow
after creating the release. In case that fails, the following steps can be performed manually

11. Push the gem from (7) to rubygems.org -- `gem push licensed-x.xx.xx.gem`
12. Build packages for new tag: `VERSION=x.xx.xx bundle exec rake package`
13. Upload packages from (12) to release from (10)

## Resources

Expand Down
Loading

0 comments on commit 79e4cc5

Please sign in to comment.