fix template error checking (#182) #124
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Upload to CDN | |
on: | |
workflow_dispatch: | |
inputs: | |
commit: | |
description: 'Commit SHA' | |
required: false | |
version: | |
description: 'Version (should follow semver v1.2.3)' | |
required: false | |
push: | |
branches: | |
- master | |
jobs: | |
test: | |
uses: ./.github/workflows/ci-go.yaml | |
secrets: inherit | |
build: | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/[email protected] | |
with: | |
ref: ${{ github.event.inputs.commit || 'master' }} | |
- name: Setup Go Environment | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: go.mod | |
- name: Set BINARY_NAME | |
id: set_binary_name | |
env: | |
VERSION: ${{ github.event.inputs.version || 'v1' }} | |
run: | | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
echo "BINARY_NAME=atlas-action-$VERSION" >> $GITHUB_ENV | |
- name: Compile Go Binary | |
run: | | |
go build -o $BINARY_NAME -ldflags "-X ariga.io/atlas-action/atlasaction.Version=${{ github.event.inputs.version || 'v1' }}" ./cmd/atlas-action | |
env: | |
CGO_ENABLED: 0 | |
- name: Install Atlas | |
uses: ariga/setup-atlas@v0 | |
- name: Check version | |
run: | | |
OUTPUT=$(./$BINARY_NAME --version) | |
[ $(echo $OUTPUT | grep -i "^$VERSION") ] && echo Version=$OUTPUT || (echo "unexpected output: $OUTPUT, expected: $VERSION"; exit 1) | |
- name: Configure AWS credentials | |
run: | | |
aws configure set aws_access_key_id ${{ secrets.RELEASE_AWS_ACCESS_KEY_ID }} | |
aws configure set aws_secret_access_key ${{ secrets.RELEASE_AWS_SECRET_ACCESS_KEY }} | |
- name: Upload binary to S3 | |
env: | |
AWS_REGION: us-east-1 | |
run: | | |
aws s3 cp $BINARY_NAME s3://release.ariga.io/atlas-action/$BINARY_NAME | |
# Run end-to-end test on the published binary. | |
e2e-test: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ariga/setup-atlas@master | |
with: | |
cloud-token: ${{ secrets.INTEGRATION_ATLAS_CLOUD_TOKEN }} | |
- name: "Run Migrate Lint" | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
uses: jenseng/dynamic-uses@v1 | |
with: | |
uses: ariga/atlas-action/migrate/lint@${{ github.event.inputs.version || 'v1' }} | |
with: '{ | |
"dir": "file://atlasaction/testdata/migrations", | |
"dev-url": "sqlite://dev?mode=memory", | |
"dir-name": "test-dir" | |
}' | |
- name: "Run Migrate Push" | |
uses: jenseng/dynamic-uses@v1 | |
with: | |
uses: ariga/atlas-action/migrate/push@${{ github.event.inputs.version || 'v1' }} | |
with: '{ | |
"dir": "file://atlasaction/testdata/migrations", | |
"dev-url": "sqlite://dev?mode=memory", | |
"dir-name": "test-dir" | |
}' |