Nightly Release #64
This file contains hidden or 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: Nightly Release | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| generate: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| changes_made: ${{ steps.commit_changes.outputs.changes_made }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.24' | |
| - name: Run generate command | |
| run: go run . generate | |
| env: | |
| AWSMETA_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check for changes | |
| id: git-diff | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add . | |
| if git diff --cached --quiet; then | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| else | |
| current_date=$(date +'%Y-%m-%d') | |
| git commit -m "Nightly update: $current_date" | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Push changes if any | |
| if: steps.git-diff.outputs.changed == 'true' | |
| run: git push origin main | |
| - name: Get latest tag | |
| if: steps.git-diff.outputs.changed == 'true' | |
| id: get-version | |
| run: | | |
| latest=$(git tag --sort=-creatordate | head -n 1) | |
| if [[ -z "$latest" ]]; then | |
| next="v0.0.0" | |
| else | |
| IFS='.' read -r major minor patch <<< "${latest#v}" | |
| next="v$major.$((minor+1)).0" | |
| fi | |
| echo "next_tag=$next" >> $GITHUB_OUTPUT | |
| - name: Build Go binary | |
| if: steps.git-diff.outputs.changed == 'true' | |
| run: go build -o aws-meta . | |
| - name: Package data manifests | |
| if: steps.git-diff.outputs.changed == 'true' | |
| run: | | |
| mkdir -p release/aws-meta-data | |
| cp -r pkg/data/manifests/* release/aws-meta-data/ | |
| cd release | |
| zip -r aws-meta-data.zip aws-meta-data/ | |
| - name: Package services | |
| if: steps.git-diff.outputs.changed == 'true' | |
| run: | | |
| mkdir -p release/aws-meta-services | |
| cp pkg/services/list.go release/aws-meta-services/ | |
| cd release | |
| zip -r aws-meta-services.zip aws-meta-services/ | |
| - name: Get current date | |
| if: steps.git-diff.outputs.changed == 'true' | |
| id: date | |
| run: echo "current=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | |
| - name: Create GitHub release with assets | |
| if: steps.git-diff.outputs.changed == 'true' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| tag_name: ${{ steps.get-version.outputs.next_tag }} | |
| name: Release ${{ steps.get-version.outputs.next_tag }} | |
| generate_release_notes: true | |
| files: | | |
| ./release/aws-meta-data.zip | |
| ./release/aws-meta-services.zip | |
| ./aws-meta | |
| body: | | |
| Automated nightly release created on ${{ steps.date.outputs.current }} | |
| This release contains all changes since the previous release. | |
| - name: Tag and push new version | |
| if: steps.git-diff.outputs.changed == 'true' | |
| run: | | |
| git tag ${{ steps.get-version.outputs.next_tag }} | |
| git push origin ${{ steps.get-version.outputs.next_tag }} | |
| - name: Publish Go module (Go proxy) | |
| if: steps.git-diff.outputs.changed == 'true' | |
| run: | | |
| # No special step needed – once the version tag is pushed, | |
| # it is available via the public Go proxy: | |
| # https://proxy.golang.org/<module>@v<version> | |
| echo "Go module published at tag ${{ steps.get-version.outputs.next_tag }}" |