Skip to content

Commit

Permalink
Fix script error (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
ichung08 authored Aug 21, 2024
1 parent 532f085 commit b5b5f97
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 23 deletions.
22 changes: 13 additions & 9 deletions .github/workflows/build-release-import-script.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build and Release Import Script
on:
push:
tags:
- 'import-v*'
- 'import/v*'

permissions:
contents: write
Expand All @@ -20,7 +20,12 @@ jobs:
go-version-file: 'go.mod'
cache: true
- run: go mod download
- run: go build -v -o import ./import/import_script.go
- run: go build -v -o terraform-import-script ./import/import_script.go
- name: Upload Terraform import script artifact
uses: actions/upload-artifact@v3
with:
name: terraform-import-script
path: terraform-import-script

lint:
name: Lint
Expand All @@ -36,30 +41,29 @@ jobs:
- run: make validate-fmt

goreleaser:
needs: [build, lint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: 0
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version-file: 'go.mod'
cache: true
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0
uses: crazy-max/ghaction-import-gpg@v5
id: import_gpg
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@5742e2a039330cbb23ebf35f046f814d4c6ff811 # v5.1.0
with:
args: release --clean --config .goreleaser.import.yml # Use the import-specific config
args: release --clean --config .goreleaser.import.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
- name: Upload Terraform import script artifact
- name: Upload GoReleaser artifacts
uses: actions/upload-artifact@v3
with:
name: import
path: dist/import*
name: goreleaser-artifacts
path: dist/*
34 changes: 22 additions & 12 deletions .goreleaser.import.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project_name: terraform-import-script

builds:
- main: ./import/import.go
- main: ./import/import_script.go
binary: terraform-import-script
goos:
- linux
Expand All @@ -10,11 +10,15 @@ builds:
goarch:
- amd64
- arm64
env:
- CGO_ENABLED=0
ldflags:
- '-s -w'

archives:
- format: tar.gz
name_template: >-
{{ .ProjectName }}_
{{ .ProjectName }}_{{ .Version }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
Expand All @@ -23,26 +27,32 @@ archives:
- goos: windows
format: zip

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
checksum:
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
algorithm: sha256

signs:
- cmd: gpg
- artifacts: checksum
args:
- "--batch"
- "--local-user"
- "{{ .Env.GPG_FINGERPRINT }}"
- "--output"
- "${signature}"
- "--detach-sign"
- "${artifact}"
artifacts: checksum

# Customize the release name to differentiate it from your main project releases
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

release:
name_template: "Terraform Import Script {{.Tag}}"
header: |
# Terraform Import Script Release {{.Tag}}
This release contains the Terraform import script, a standalone tool for importing resources into Terraform.
This release contains the Terraform import script, a standalone tool for importing resources into Terraform.
prerelease: auto
6 changes: 4 additions & 2 deletions import/import_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,10 @@ provider "astro" {
}(resource)
}

wg.Wait()
close(results)
go func() {
wg.Wait()
close(results)
}()

var allResults []HandlerResult
var deploymentImportString string
Expand Down

0 comments on commit b5b5f97

Please sign in to comment.