Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: create release for tag #394

Merged
merged 4 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
20 changes: 11 additions & 9 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,33 @@ on:
- dev
- test
- prod
release:
types:
- published
tags:
# pre-release tag
- "202[3-9].[0-9][0-9].[0-9]+-rc[0-9]+"
# release tags
- "202[3-9].[0-9][0-9].[0-9]+"

defaults:
run:
shell: bash

concurrency:
# this expression gives us the name of the deployment environment. It works like a ternary operation (see https://github.com/actions/runner/issues/409#issuecomment-727565588)
group: ${{ github.event_name != 'release' && github.ref_name || github.event.release.prerelease && 'test' || 'prod' }}
group: ${{ !startsWith(github.ref, 'refs/tags/') && github.ref_name || contains(github.ref, '-rc') && 'test' || 'prod' }}
thekaveman marked this conversation as resolved.
Show resolved Hide resolved
cancel-in-progress: true

jobs:
test:
uses: ./.github/workflows/run-tests.yml
if: github.event_name == 'release'
if: startsWith(github.ref, 'refs/tags/')

deploy:
needs: test
# !cancelled() is needed because if the whole workflow was cancelled, we don't want this job to run.
# (github.event_name != 'release' || needs.test.result == 'success') is needed because if `test` did run, we only want this to run if `test` succeeded.
if: (!cancelled() && (github.event_name != 'release' || needs.test.result == 'success'))
# (!startsWith(github.ref, 'refs/tags/') || needs.test.result == 'success') is needed because if `test` did run, we only want this to run if `test` succeeded.
if: (!cancelled() && (!startsWith(github.ref, 'refs/tags/') || needs.test.result == 'success'))
runs-on: ubuntu-latest
environment: ${{ github.event_name != 'release' && github.ref_name || github.event.release.prerelease && 'test' || 'prod' }}
environment: ${{ !startsWith(github.ref, 'refs/tags/') && github.ref_name || contains(github.ref, '-rc') && 'test' || 'prod' }}

steps:
- name: Checkout
Expand Down Expand Up @@ -85,6 +87,6 @@ jobs:
file: Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ github.event_name != 'release' && github.ref_name || github.event.release.prerelease && 'test' || 'prod' }}
ghcr.io/${{ github.repository }}:${{ !startsWith(github.ref, 'refs/tags/') && github.ref_name || contains(github.ref, '-rc') && 'test' || 'prod' }}
ghcr.io/${{ github.repository }}:${{ github.ref_name }}
ghcr.io/${{ github.repository }}:${{ github.sha }}
23 changes: 23 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
on:
push:
Copy link
Member

Choose a reason for hiding this comment

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

Looks like some extra space here

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, fixed it in c521775

tags:
# pre-release tag
- "202[3-9].[0-9][0-9].[0-9]+-rc[0-9]+"
angela-tran marked this conversation as resolved.
Show resolved Hide resolved
# release tags
- "202[3-9].[0-9][0-9].[0-9]+"

jobs:
release:
runs-on: ubuntu-latest
permissions:
# https://github.com/softprops/action-gh-release#permissions
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Release
uses: softprops/action-gh-release@v1
with:
prerelease: ${{ contains(github.ref, '-rc') }}
generate_release_notes: ${{ !contains(github.ref, '-rc') }}
Loading