|
14 | 14 | create_tag: |
15 | 15 | name: Publish artifacts of build |
16 | 16 | runs-on: ubuntu-latest |
17 | | - if: | |
18 | | - github.repository_owner == 'bytecodealliance' |
19 | | - && github.event_name == 'push' |
20 | | - && github.ref == 'refs/heads/main' |
21 | 17 | steps: |
22 | | - - uses: actions/checkout@v4 |
23 | | - with: |
24 | | - submodules: true |
25 | | - fetch-depth: 0 |
26 | | - |
27 | | - - run: rustup update stable && rustup default stable |
28 | | - |
29 | | - # If this is a push to `main` see if the push has an indicator saying that |
30 | | - # a tag should be made. If so create one and push it. |
31 | | - - name: Test if tag is needed |
32 | | - run: | |
33 | | - git log ${{ github.event.before }}...${{ github.event.after }} | tee main.log |
34 | | - version=$(./ci/print-current-version.sh) |
35 | | - echo "version: $version" |
36 | | - echo "version=$version" >> $GITHUB_OUTPUT |
37 | | - echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT |
38 | | - if grep -q "automatically-tag-and-release-this-commit" main.log; then |
39 | | - echo push-tag |
40 | | - echo "push_tag=yes" >> $GITHUB_OUTPUT |
41 | | - else |
42 | | - echo no-push-tag |
43 | | - echo "push_tag=no" >> $GITHUB_OUTPUT |
44 | | - fi |
45 | | - id: tag |
46 | | - |
47 | | - - name: Push the tag |
48 | | - run: | |
49 | | - git_refs_url=$(jq .repository.git_refs_url $GITHUB_EVENT_PATH | tr -d '"' | sed 's/{\/sha}//g') |
50 | | - curl -iX POST $git_refs_url \ |
51 | | - -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
52 | | - -d @- << EOF |
53 | | - { |
54 | | - "ref": "refs/tags/v${{ steps.tag.outputs.version }}", |
55 | | - "sha": "${{ steps.tag.outputs.sha }}" |
56 | | - } |
57 | | - EOF |
58 | | - if: steps.tag.outputs.push_tag == 'yes' |
59 | | - |
60 | | - - run: | |
61 | | - sha=${{ github.sha }} |
62 | | - run_id=$( |
63 | | - gh api -H 'Accept: application/vnd.github+json' \ |
64 | | - /repos/${{ github.repository }}/actions/workflows/main.yml/runs\?exclude_pull_requests=true \ |
65 | | - | jq '.workflow_runs' \ |
66 | | - | jq "map(select(.head_commit.id == \"$sha\"))[0].id" \ |
67 | | - ) |
68 | | - gh run download $run_id |
69 | | - ls |
70 | | - find bins-* |
71 | | - mkdir dist |
72 | | - mv bins-*/* dist |
73 | | - env: |
74 | | - GH_TOKEN: ${{ github.token }} |
75 | | -
|
76 | | - - uses: softprops/action-gh-release@v1 |
77 | | - if: steps.tag.outputs.push_tag == 'yes' |
78 | | - with: |
79 | | - files: "dist/*" |
80 | | - generate_release_notes: true |
81 | | - tag_name: v${{ steps.tag.outputs.version }} |
82 | | - |
83 | | - - run: | |
84 | | - rm -rf dist main.log |
85 | | - rustc ci/publish.rs |
86 | | - ./publish publish |
87 | | - env: |
88 | | - CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |
89 | | - if: steps.tag.outputs.push_tag == 'yes' |
| 18 | + - uses: ./.github/actions/publish-release |
0 commit comments