Skip to content

Commit

Permalink
Workflow Release (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
boonya authored Jun 18, 2022
1 parent 9624607 commit 71710d4
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 12 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: "Build and publish 🏭"

on:
workflow_call:
push:
tags:
- "*"
Expand All @@ -13,7 +14,7 @@ env:

jobs:
bundle:
name: Build Meteor Bundle 📦
name: Meteor Bundle 📦
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -42,6 +43,11 @@ jobs:
)
echo ${META} > meta.json
echo "meteor version: ${METEOR}"
echo "package version: ${VERSION}"
echo "hash: ${HASH}"
echo "bundle name: ${BUNDLE}"
- uses: meteorengineer/setup-meteor@v1
with:
meteor-release: ${{ steps.meta.outputs.meteor }}
Expand Down Expand Up @@ -70,7 +76,7 @@ jobs:
if-no-files-found: error

docker:
name: Build Docker Image 🐳
name: Docker Image 🐳
runs-on: ubuntu-20.04
needs: [bundle]
steps:
Expand All @@ -88,11 +94,13 @@ jobs:
HASH=$(cat meta.json | jq -r '.hash')
TAGS="${{ env.GHCR_IMAGE }}:${HASH},${{ env.GHCR_IMAGE }}:${GITHUB_REF_NAME}"
if [[ $GITHUB_REF == ref/head/main ]]; then
TAGS="${TAGS},${{ env.GHCR_IMAGE }}:${VERSION}"
fi
echo ::set-output name=tags::${TAGS}
echo "package version: ${VERSION}"
echo "bundle name: ${BUNDLE}"
echo "hash: ${HASH}"
echo "tags: ${TAGS}"
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
Expand Down
42 changes: 36 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,34 @@ env:
DOCKER_HUB_IMAGE: "${{ github.repository }}"

jobs:
version:
name: Compare tag and package version
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: "Check"
run: |
VERSION=$(cat package.json | jq -r '.version')
if [[ ${GITHUB_REF_NAME} != ${VERSION} ]];
then
echo "Tag (${GITHUB_REF_NAME}) and package version (${VERSION}) are different."
echo "Something went wrong."
exit 1
fi
verify:
needs: [version]
uses: ./.github/workflows/verify.yml

build:
needs: [verify, version]
uses: ./.github/workflows/build.yml
secrets: inherit

release:
name: Copy Images from GHCR to DockerHub
runs-on: ubuntu-20.04
needs: [build]
steps:
- name: Login to DockerHub
uses: docker/login-action@v2
Expand All @@ -26,11 +51,16 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN_RW }}

- name: Prepare source and targets
id: meta
run: |
SRC="${{ env.GHCR_IMAGE }}:${GITHUB_REF_NAME}"
echo ::set-output name=src::${SRC}
DST="${{ env.GHCR_IMAGE }}:${GITHUB_REF_NAME},${{ env.GHCR_IMAGE }}:latest,${{ env.DOCKER_HUB_IMAGE }}:${GITHUB_REF_NAME},${{ env.DOCKER_HUB_IMAGE }}:latest"
echo ::set-output name=dst::${DST}
- name: Push Image
uses: akhilerm/tag-push-action@v2
uses: akhilerm/tag-push-action@v2.0.0
with:
src: "${{ env.GHCR_IMAGE }}:${GITHUB_REF_NAME}"
dst: |
"${{ env.DOCKER_HUB_IMAGE }}:latest"
"${{ env.DOCKER_HUB_IMAGE }}:${GITHUB_REF_NAME}"
"${{ env.GHCR_IMAGE }}:latest"
src: ${{ steps.meta.outputs.src }}
dst: ${{ steps.meta.outputs.dst }}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: "Verification 👮🏽‍♂️"

on:
workflow_call:
push:
tags-ignore: ["*"]
paths-ignore: ["**.md", "LICENSE"]
Expand All @@ -10,7 +11,7 @@ on:

jobs:
versions:
name: Verify versions
name: Versions
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
Expand Down

0 comments on commit 71710d4

Please sign in to comment.