Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Trigger publish from release workflow #193

Merged
merged 3 commits into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 0 additions & 116 deletions .github/workflows/deploy.yml

This file was deleted.

80 changes: 80 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Publish

on:
release:
types: [created, published]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know what's the difference between these two? It doesn't seem to be documented in the trigger events doc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure, but GitHub's UI copy gives us some clue. On the releases page, the button says "Draft a new release". On that page, there are two buttons, "Publish release" or "Save as draft". The former likely corresponds to a published event, and the latter may trigger a created step.

Here, we're creating a release through the github/create-release action, whose name implies a created event, but I vaguely recall triggering published instead. It's really too bad that there's no easy way to do a dry run of this.


jobs:
formula:
name: Update Homebrew formula
runs-on: ubuntu-latest
steps:
- name: Update the Homebrew formula with latest release
uses: NSHipster/update-homebrew-formula-action@main
with:
repository: SwiftDocOrg/swift-doc
tap: SwiftDocOrg/homebrew-formulae
formula: Formula/swift-doc.rb
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

bottle:
name: Build and distribute Homebrew bottle for macOS Catalina
runs-on: macos-10.15
needs: [formula]
steps:
- name: Build a bottle using Homebrew
run: |
brew tap swiftdocorg/formulae
brew install --build-bottle --verbose swift-doc
brew bottle swift-doc
- name: Upload the bottle to the GitHub release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./swift-doc--${{ github.event.release.tag_name }}.catalina.bottle.tar.gz
asset_name: swift-doc-${{ github.event.release.tag_name }}.catalina.bottle.tar.gz
asset_content_type: application/gzip
- name: Update the Homebrew formula again with bottle
uses: NSHipster/update-homebrew-formula-action@main
with:
repository: SwiftDocOrg/swift-doc
tap: SwiftDocOrg/homebrew-formulae
formula: Formula/swift-doc.rb
message: |
Add bottle for swift-doc ${{ github.event.release.tag_name }}
on macOS Catalina
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

docker:
name: Build and push Docker container

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.release.tag_name }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: true
tags: |
swiftdoc/swift-doc:latest
swiftdoc/swift-doc:${{ github.event.release.tag_name }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
Expand Down