Skip to content

Commit

Permalink
Create GitHub release after tagging the repo
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoy committed Feb 1, 2024
1 parent c47d1f0 commit f0624ec
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 17 deletions.
51 changes: 51 additions & 0 deletions .github/actions/create-tag-and-github-release/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Tag Repository and Create GitHub Release
description: Tags the repository and creates a GitHub release
inputs:
prerelease:
description: "Whether the release is a prerelease"
required: false
type: boolean
default: true
GH_TOKEN:
description: "GitHub token"
required: true
type: string
outputs:
tag:
description: "Tag that has been added"
value: ${{ steps.compute-tag.outputs.tag }}
runs:
using: "composite"
steps:
- run: |
git config --global user.name "Dax the Duck"
git config --global user.email "[email protected]"
shell: bash
- id: compute-tag
run: |
version="$(cut -d ' ' -f 3 < Configuration/Version.xcconfig)"
if [[ "${{ inputs.prerelease }}" == "true" ]]; then
build_number="$(cut -d ' ' -f 3 < Configuration/BuildNumber.xcconfig)"
tag="${version}-${build_number}"
else
tag="${version}"
fi
echo "tag=${tag}" >> $GITHUB_OUTPUT
shell: bash

- id: tag-repo
run: |
git tag ${{ steps.compute-tag.outputs.tag }}
git push origin ${{ steps.compute-tag.outputs.tag }}
shell: bash

- id: create-github-release
run: |
latest_release="$(gh api /repos/${{ github.repository }}/releases/latest --jq '.tag_name')"
if [[ "${{ inputs.prerelease }}" == "true" ]]; then
gh release create ${{ steps.compute-tag.outcome.tag }} --generate-notes --prerelease --notes-start-tag ${latest_release}
else
gh release create ${{ steps.compute-tag.outcome.tag }} --generate-notes --notes-start-tag ${latest_release}
fi
shell: bash
22 changes: 5 additions & 17 deletions .github/workflows/tag_and_merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,11 @@ jobs:
access-token: ${{ secrets.ASANA_ACCESS_TOKEN }}
task-id: ${{ steps.get-task-id.outputs.task-id }}

- name: Set up git
run: |
git config --global user.name "Dax the Duck"
git config --global user.email "[email protected]"
- name: Construct a tag
id: construct-tag
run: |
version="$(cut -d ' ' -f 3 < Configuration/Version.xcconfig)"
build_number="$(cut -d ' ' -f 3 < Configuration/BuildNumber.xcconfig)"
tag="${version}-${build_number}"
echo "tag=${tag}" >> $GITHUB_OUTPUT
- name: Tag the repo
run: |
git tag ${{ steps.construct-tag.outputs.tag }}
git push origin ${{ steps.construct-tag.outputs.tag }}
- name: Create Tag and GitHub Release
uses: ./.github/actions/create-tag-and-github-release
with:
prerelease: true
GH_TOKEN: ${{ github.token }}

- name: Merge to base branch
id: merge
Expand Down

0 comments on commit f0624ec

Please sign in to comment.