Skip to content

Release

Release #13

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
service:
description: Deploy app service
required: true
type: choice
options:
- frontend
- lambdas
concurrency:
group: "release-${{ inputs.service }}"
cancel-in-progress: false
jobs:
# verified:
# uses: ./.github/workflows/verify.yml
create-git-tag:
runs-on: ubuntu-latest
# needs: [ verified ]
steps:
- if: github.ref != 'refs/heads/main'
run: exit 1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- name: tag
id: tag
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SERVICE: ${{ inputs.service }}
run: |
DATE="$(git show -s --format=%ci $HASH | cut -c1-10)"
HASH="$(git rev-parse --short HEAD)"
VERSION="$DATE.$HASH"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
git config --global user.name "Adam McKee"
git config --global user.email "[email protected]"
TAG_NAME="$SERVICE-v$VERSION"
git tag $TAG_NAME
git push --atomic origin main $TAG_NAME
echo "tag_name=$TAG_NAME" >> "$GITHUB_OUTPUT"
outputs:
tag_name: ${{ steps.tag.outputs.tag_name }}
version: ${{ steps.tag.outputs.version }}
create-gh-release:
runs-on: ubuntu-latest
needs: [ create-git-tag ]
steps:
- name: create github release
id: create
env:
TAG_NAME: ${{ needs.create-git-tag.outputs.tag_name }}
VERSION: ${{ needs.create-git-tag.outputs.version }}
GH_TOKEN: ${{ github.token }}
run: |
CREATED_RELEASE=$(gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/eighty4/install.sh/releases \
-f tag_name="$TAG_NAME" \
-f name="${{ inputs.service }} $VERSION" \
-F body="https://github.com/eighty4/install.sh/tree/$TAG_NAME" \
-F draft=false \
-F prerelease=false \
-F generate_release_notes=false)
echo "release_id=$(echo $CREATED_RELEASE | jq '.id')" >> "$GITHUB_OUTPUT"
echo "upload_hostname=$(echo $CREATED_RELEASE | jq '.upload_url' | cut -d'/' -f3)" >> "$GITHUB_OUTPUT"
outputs:
tag_name: ${{ needs.create-git-tag.outputs.tag_name }}
release_id: ${{ steps.create.outputs.release_id }}
upload_hostname: ${{ steps.create.outputs.upload_hostname }}
publish-frontend:
if: inputs.service == 'frontend'
needs: create-gh-release
uses: ./.github/workflows/publish_frontend.yml
with:
release_id: ${{ needs.create-gh-release.outputs.release_id }}
tag_name: ${{ needs.create-gh-release.outputs.tag_name }}
upload_hostname: ${{ needs.create-gh-release.outputs.upload_hostname }}
secrets: inherit
publish-lambdas:
if: inputs.service == 'lambdas'
needs: create-gh-release
uses: ./.github/workflows/publish_lambdas.yml
with:
release_id: ${{ needs.create-gh-release.outputs.release_id }}
tag_name: ${{ needs.create-gh-release.outputs.tag_name }}
upload_hostname: ${{ needs.create-gh-release.outputs.upload_hostname }}
secrets: inherit