diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..b2e7a00 --- /dev/null +++ b/.github/workflows/release.yaml @@ -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 "cicd@spacelift.io" + 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 + + \ No newline at end of file diff --git a/README.md b/README.md index 6d3b1d7..28fc5c9 100644 --- a/README.md +++ b/README.md @@ -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}"