Alpha version, generated from commit 3cb7cc94786994c6cf80a43a2ed81fdf… #44
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'release' | |
on: | |
push: | |
branches: | |
- 'releases/*' | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Check if tag already exists | |
run: | | |
# Get version from package.json (head is needed because this also returns "version" npm script line) | |
sed -n '/version/s/,*\r*$//p' package.json | cut -d ':' -f2,3 | sed -e 's/^ "//' -e 's/"$//' | head -n 1 > app_version.tmp | |
cat app_version.tmp | cut -d. -f1 > major_version.tmp | |
export VERSION_TAG="v$(cat app_version.tmp)" | |
echo "package_version=$(cat app_version.tmp)" >> $GITHUB_ENV | |
echo "major_version=$(cat major_version.tmp)" >> $GITHUB_ENV | |
# Check if tag already exists | |
if [ $(git tag -l "$VERSION_TAG") ]; then | |
echo "Tag already exists, please increment version to create release" | |
echo "create_release=no" >> $GITHUB_ENV | |
else | |
echo "create_release=yes" >> $GITHUB_ENV | |
fi | |
- name: Docker meta Release | |
if: ${{ env.create_release == 'yes' }} | |
id: meta | |
uses: docker/metadata-action@v3 | |
with: | |
# list of Docker images to use as base name for tags | |
images: | | |
boringdownload/jira-integration | |
ghcr.io/rohit-gohri/jira-ci-cd-integration | |
# registry.gitlab.com/rohit-gohri/jira-ci-cd-integration | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
type=ref,event=branch | |
type=semver,pattern={{version}},value=v${{ env.package_version }} | |
type=semver,pattern=v{{major}},value=v${{ env.package_version }} | |
type=sha | |
- name: Docker meta Alpha | |
if: ${{ env.create_release == 'no' }} | |
id: meta-latest | |
uses: docker/metadata-action@v3 | |
with: | |
# list of Docker images to use as base name for tags | |
images: | | |
boringdownload/jira-integration | |
ghcr.io/rohit-gohri/jira-ci-cd-integration | |
# registry.gitlab.com/rohit-gohri/jira-ci-cd-integration | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
type=raw,value=alpha | |
type=sha | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v1 | |
with: | |
driver-opts: network=host | |
- name: 🛂 Log in to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: 🛂 Log in to the Github Container registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# - name: 🛂 Log in to the Gitlab Container registry | |
# uses: docker/login-action@v1 | |
# with: | |
# registry: registry.gitlab.com | |
# username: ${{ secrets.GITLAB_USERNAME }} | |
# password: ${{ secrets.GITLAB_TOKEN }} | |
- name: 🔨🚀 Build and push Release | |
if: ${{ env.create_release == 'yes' }} | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
builder: ${{ steps.buildx.outputs.name }} | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: 🔨🚀 Build and push Alpha | |
if: ${{ env.create_release == 'no' }} | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
builder: ${{ steps.buildx.outputs.name }} | |
push: true | |
tags: ${{ steps.meta-latest.outputs.tags }} | |
labels: ${{ steps.meta-latest.outputs.labels }} | |
action: | |
runs-on: ubuntu-latest | |
needs: docker | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.DRONE_USER_TOKEN }} | |
- name: Check if tag already exists | |
run: | | |
# Get version from package.json (head is needed because this also returns "version" npm script line) | |
sed -n '/version/s/,*\r*$//p' package.json | cut -d ':' -f2,3 | sed -e 's/^ "//' -e 's/"$//' | head -n 1 > app_version.tmp | |
cat app_version.tmp | cut -d. -f1 > major_version.tmp | |
export VERSION_TAG="v$(cat app_version.tmp)" | |
echo "package_version=$(cat app_version.tmp)" >> $GITHUB_ENV | |
echo "major_version=$(cat major_version.tmp)" >> $GITHUB_ENV | |
# Check if tag already exists | |
if [ $(git tag -l "$VERSION_TAG") ]; then | |
echo "Tag already exists, please increment version to create release" | |
echo "create_release=no" >> $GITHUB_ENV | |
else | |
echo "create_release=yes" >> $GITHUB_ENV | |
fi | |
- name: 🚀 Release | |
uses: softprops/action-gh-release@v1 | |
if: ${{ env.create_release == 'yes' }} | |
with: | |
tag_name: v${{ env.package_version }} | |
target_commitish: ${{ github.sha }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.DRONE_USER_TOKEN }} | |
- name: 🚀 Tag Major Version | |
if: ${{ env.create_release == 'yes' }} | |
run: | | |
git config user.name rohit-drone | |
git config user.email [email protected] | |
git tag -fa v${{ env.major_version }} -m "Update v${{ env.major_version }} tag" | |
git push origin v${{ env.major_version }} --force |