Skip to content

Fix main branch building with no version. #42

Fix main branch building with no version.

Fix main branch building with no version. #42

Workflow file for this run

name: build
on:
push:
branches:
- main
- 'release/**'
pull_request:
branches:
- main
- 'release/**'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOPATH: ${{ github.workspace }}/provider/cmd
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
# Used for pulumictl to calculate the correct tags :(
- name: Unshallow clone for tags
run: git fetch --prune --unshallow --tags
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x
- name: Install pulumictl
uses: jaxxstorm/action-install-gh-release@c5ead9a448b4660cf1e7866ee22e4dc56538031a # v1.10.0
with:
repo: pulumi/pulumictl
- name: Install Pulumi CLI
uses: pulumi/action-install-pulumi-cli@v2
- name: Install Schema Tools
if: github.event_name == 'pull_request'
uses: jaxxstorm/action-install-gh-release@c5ead9a448b4660cf1e7866ee22e4dc56538031a # v1.10.0
with:
repo: pulumi/schema-tools
- name: Build
run: |
export VERSION=`echo $GITHUB_REF | sed -e "s/refs\/heads\///g" -e "s/release\/\|main//g"`
export VERSION="v${VERSION:-0.0}.${GITHUB_RUN_NUMBER:-0}"
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "GORELEASER_CURRENT_TAG=${VERSION}" >> $GITHUB_ENV
# sed -i "s/0.0.0/${VERSION}/g" src/version.go
make tfgen
make provider
- name: Create Github Release and Tag
if: github.repository_owner == 'Authress' && github.ref != 'refs/heads/main' && github.event_name == 'push'
run: |
# Before we go any further we'll deploy this branch to the mainline, if it works great. If not we'll skip it
git push origin HEAD:main || echo "Skipping merging into main because this branch is not ahead of the mainline branch"
# the schema.json is read by pulumi directly from the repo, so it has to be there, and it can be updated dynamically by everything, so we really don't want it present otherwise
# So we'll generate it during the build and then commit it.
git add provider/cmd/pulumi-resource-authress/schema.json && git commit -m"Committing updated schema.json" || echo "schema.json is up to date."
git tag ${VERSION} -f
git push origin ${VERSION}
- name: Import GPG key
if: github.repository_owner == 'Authress' && github.ref != 'refs/heads/main' && github.event_name == 'push'
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
- name: Run GoReleaser
if: github.repository_owner == 'Authress' && github.ref != 'refs/heads/main' && github.event_name == 'push'
uses: goreleaser/goreleaser-action@f82d6c1c344bcacabba2c841718984797f664a6b # v4.2.0
with:
args: -p 3 release --clean
version: latest
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: List all files (on failure)
if: failure()
run: |
ls -alR