Skip to content

Commit

Permalink
Add tagging logic to master branch (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdeme authored Jan 13, 2023
1 parent 3916355 commit 0f00323
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
50 changes: 50 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Create tag and release 🚀

on:
push:
branches: [master]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
with:
fetch-depth: 0

- name: Get version number from .spacelift/config.yml
run: |
VERSION=$(docker run --rm -i -v "${PWD}":/workdir mikefarah/yq '.module_version' < ./.spacelift/config.yml)
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Create & push tag if not exists
run: |
git config --local user.email "[email protected]"
git config --local user.name "Spacelift CI/CD"
if git rev-parse "v${VERSION}" >/dev/null 2>&1; then
echo "Tag v${VERSION} already exists"
echo "CREATE_RELEASE=false" >> $GITHUB_ENV
else
echo "Creating tag v${VERSION}"
git tag -a "v${VERSION}" -m "v${VERSION}"
git push origin "v${VERSION}"
echo "CREATE_RELEASE=true" >> $GITHUB_ENV
fi
- name: Create release if not exists
if: env.CREATE_RELEASE == 'true'
uses: ncipollo/release-action@v1
with:
tag: "v${{ env.VERSION }}"
generateReleaseNotes: true
allowUpdates: true
draft: false
prerelease: false


2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ terraform {
}
module "my_workerpool" {
source = "github.com/spacelift-io/terraform-aws-spacelift-workerpool-on-ec2"
source = "github.com/spacelift-io/terraform-aws-spacelift-workerpool-on-ec2?ref=v1.3.0"
configuration = <<-EOT
export SPACELIFT_TOKEN="${var.worker_pool_config}"
Expand Down

0 comments on commit 0f00323

Please sign in to comment.